Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260521022217.GR1827@brightrain.aerifal.cx>
Date: Wed, 20 May 2026 22:22:18 -0400
From: Rich Felker <dalias@...c.org>
To: Sertonix <sertonix@...teo.net>
Cc: musl@...ts.openwall.com
Subject: Re: strtod:

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.

Rich

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.