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: Tue, 23 Aug 2022 13:30:20 -0400 [thread overview]
Message-ID: <20220823173020.GJ7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <CA+fZqCUStmtAoWfy+ffpdgFKq6x+Ce_PpCwy+kLR4cgiTLh=YA@mail.gmail.com>
On Tue, Aug 23, 2022 at 07:00:41PM +0200, ardi wrote:
> On Fri, Aug 19, 2022 at 5:19 AM Rich Felker <dalias@libc.org> wrote:
> >
> > On Thu, Aug 18, 2022 at 05:51:26PM +0200, ardi wrote:
> > > Hi,
> > >
> > > I'm looking for a small and robust dtoa-like implementation for quad
> > > floats (IEEE binary128) [...]
> > >
> > I think the fmt_fp code is a very good choice for this. It's basically
> > the minimal, dependency-free, most straightforward way of doing
> > exact/correctly-rounded binary floating point to decimal conversion,
> > and it doess not depend in any way on the format of the long double
> > type, just knowing the parameters (MANT_DIG, MAX_EXP), and being able
> > to do a very minimal amount of math on the floating point type to
> > extract the mantissa and to determine rounding behavior to match the
> > floating point type's.
> >
> > If you don't have the equivalent of frexpl you can even do that part
> > with portable arithmetic on the floating point type. At one point long
> > ago I think I even had a version of the code that did that, but it
> > doesn't seem to have ever been in musl proper. It probably predated
> > musl.
> >
> > The same should apply to the floatscan.c code if you need the other
> > direction conversion too. It's just a direct dependency-free version
> > of the minimal bignum logic needed to do it.
>
> Thanks a lot. I'm working on adapting it at the moment!
>
> One question, though, because I don't know the musl internals, and
> I'm defining a custom FILE struct that has only the fields used by
> the shgetc.c source file: Can the __uflow() invocation at line 23
> of shgetc.c be called for string pseudo-FILEs, or is it guaranteed that
> it will be called for real FILE objects only?
>
> I ask the question because __uflow() drives into the stdio internals,
> and I'd prefer to avoid that (I'm implementing the fp<>string code
> for strings only).
>
> Kind regards and thanks a lot!
See how strtod.c uses sh_fromstring and how sh_fromstring does not
define any io callbacks (so that calling __uflow would necessarily
result in a call to a null or ununitialized function pointer). From
that, it's clear that it must not be reachable (or the existing code
in musl would be broken).
Rich
next prev parent reply other threads:[~2022-08-23 17:30 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 [this message]
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
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=20220823173020.GJ7074@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).