Bug 6453 - strtod() is buggy
strtod() is buggy
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
6.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-10-28 02:53 EDT by lars
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-03-04 17:21:09 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description lars 1999-10-28 02:53:37 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";'
1.25
Comment 1 Bernhard Rosenkraenzer 2000-02-17 15:10:59 EST
I've verified it's indeed a glibc problem, and still present in dist-6.2


#include <stdlib.h>
main() {
	double a=strtod("0x0a", NULL);
	printf("%f\n", a);
}
Comment 2 Cristian Gafton 2000-03-04 17:21:59 EST
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.

      7.20.1.3                   Library                  7.20.1.3

In binary notation, 0x0A = 1010 = 1.25 (for FLT_RADIX=2, whcih is the default)

Not a bug, just what the standard mandates.

Note You need to log in before you can comment on or make changes to this bug.