Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 6453 - strtod() is buggy
Summary: strtod() is buggy
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-10-28 06:53 UTC by lars
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-03-04 22:21:09 UTC


Attachments (Terms of Use)

Description lars 1999-10-28 06:53:37 UTC
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 20:10:59 UTC
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 22:21:59 UTC
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.