Red Hat Bugzilla – Bug 6453
strtod() is buggy
Last modified: 2008-05-01 11:37:52 EDT
Morning, as we just discussed on IRC, strtod("0x0a") is supposed to return 0 according to the man page,
but it does return 1.25.
This manifests itself in breaking Perl for example,
# perl -e 'print "0x0a"+0,"\n";'
I've verified it's indeed a glibc problem, and still present in dist-6.2
double a=strtod("0x0a", NULL);
Well, ISO C99 specifies that:
[#5] If the subject sequence has the hexadecimal form and
FLT_RADIX is a power of 2, the value resulting from the
conversion is correctly rounded.
18.104.22.168 Library 22.214.171.124
In binary notation, 0x0A = 1010 = 1.25 (for FLT_RADIX=2, whcih is the default)
Not a bug, just what the standard mandates.