This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6467] New: strtod "0.0" returns nonzero
- From: "eberlein at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 29 Apr 2008 17:59:08 -0000
- Subject: [Bug libc/6467] New: strtod "0.0" returns nonzero
- Reply-to: sourceware-bugzilla at sourceware dot org
Consider the following code snippet.
printf("%g", strtof("0.0", NULL))
printf("%lg", strtod("0.0", NULL))
printf("%llg", strtold("0.0", NULL))
When executed, expecting to see zeroes, the output is:
2.216671e-231
2.216671e-231
2.216671e-231
This seems to be due to strtod_l.c setting
int_no is 0
lead_zero = -1
and later
dig_no -= lead_zero
This increases the number of digits considered for fractional digits since
dig_no - int_no
is passed to str_to_mpn. This causes the null string terminator to be
considered as a digit in the fractional digits.
--
Summary: strtod "0.0" returns nonzero
Product: glibc
Version: 2.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: eberlein at us dot ibm dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6467
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.