|
|
Message-ID: <20260521025554.GS1827@brightrain.aerifal.cx>
Date: Wed, 20 May 2026 22:55:54 -0400
From: Rich Felker <dalias@...c.org>
To: Sertonix <sertonix@...teo.net>
Cc: musl@...ts.openwall.com
Subject: Re: strtod:
On Wed, May 20, 2026 at 10:22:18PM -0400, Rich Felker wrote:
> On Thu, May 21, 2026 at 01:33:13AM +0000, Sertonix wrote:
> > Hi,
> >
> > I noticed a subtle difference in the result of strtod on alpine linux
> > between arm/ppc64le and other arches. The following reproducer shows
> > 1.3754889325393114e+24 on x86_64 and 1.3754889325393111e+24 on armv7.
> > Is this maybe a musl bug or is that level of precision undefined?
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> >
> > int main() {
> > char *end;
> > double v = strtod("0x0123456789ABCDEFabcdef", &end);
> > printf("%.16e\n", v);
> > }
>
> I confirmed this report. It seems to give the wrong output (rounding
> down instead of up) on all archs with 64-bit long double (same as
> double). I'll have to step thru the execution and see where it's going
> wrong. I'll see if I can figure it out tomorrow if nobody beats me to
> it.
>
> BTW the issue is easier to see if you change the %.16e to %a.
I think this fixes it.
View attachment "floatscan-ld64-fix.diff" of type "text/plain" (475 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.