mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: ardi <ardillasdelmonte@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Do you recommend using fmt_fp() and
Date: Sun, 4 Sep 2022 17:59:28 -0400	[thread overview]
Message-ID: <20220904215927.GB9709@brightrain.aerifal.cx> (raw)
In-Reply-To: <CA+fZqCXj6VPWcSbmJTWn+Ug2rdNmcJZBarOvbfksyC3Cab1uvg@mail.gmail.com>

On Sun, Sep 04, 2022 at 09:52:35PM +0200, ardi wrote:
> On Tue, Aug 30, 2022 at 2:26 PM Rich Felker <dalias@libc.org> wrote:
> >
> > I think the scaling just needs to be large enough to ensure we get out
> > of the subnormal range but not so large as to overflow. Since it's
> > conditioned on starting out with a negative exponent in the subnormal
> > range, you'd need an exponent much larger than the max positive
> > exponent for scaling to overflow, so 113 is safe and the only point of
> > the number being 113 is that it's sufficient for both formats.
> >
> > That's just my quick reading of what's going on, so if anyone thinks
> > I'm wrong about it, please speak up.
> 
> I've left as it is, it seems to work fine. Aside from that, and as you
> pointed out, I needed a frexp() implementation for SoftFloat, and,
> because I want to have all things as complete as possible, I'm writing
> frexp() for all the types in SoftFloat (binary16, binary32 aka float,
> binary64 aka double, extended 80bit, and binary128). I'm just adapting
> the musl implementation so that it accesses the SoftFloat structs/unions.
> 
> I'm having a hard time trying to understand the code block for "if(!ee)",
> specifically the decrement amount for the exponent. frexpl() decrements
> by 120 for both 80bit and binary128 long doubles. It makes sense
> because both types have the same exponent size.

It's not about the exponent size but the mantissa size, and the
numbers 64 and 120 are completely arbitrary except for being larger
than the number of mantissa bits and small enough not to overflow (so
at most a little under twice the max exponent).

Hope this helps.

Rich

  reply	other threads:[~2022-09-04 21:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 15:51 ardi
2022-08-19  3:19 ` Rich Felker
2022-08-23 17:00   ` ardi
2022-08-23 17:30     ` Rich Felker
2022-08-30 10:17       ` ardi
2022-08-30 12:26         ` Rich Felker
2022-09-04 19:52           ` ardi
2022-09-04 21:59             ` Rich Felker [this message]
2022-09-05  8:49               ` ardi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220904215927.GB9709@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=ardillasdelmonte@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).