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

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.

Then frexp() decrements by 64. It also seems to make sense because
the exponent is smaller in binary64.

However, frexpf() also decrements by 64. Why? And what's the reason
for choosing 64 and 120? I couldn't find from where they come.

For binary16 I'm replicating all the same logic, but no idea on the
amount for decrementing the exponent on "if(!ee)". If I can understand
how 64 and 120 where chosen for the other types, I'll be able to find it
for binary16.

Thanks again,

César

  reply	other threads:[~2022-09-04 19:53 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 [this message]
2022-09-04 21:59             ` Rich Felker
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=CA+fZqCXj6VPWcSbmJTWn+Ug2rdNmcJZBarOvbfksyC3Cab1uvg@mail.gmail.com \
    --to=ardillasdelmonte@gmail.com \
    --cc=dalias@libc.org \
    --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).