This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3674] New: strtod trailing zero removal doesn't allow for hex floats
- From: "jsm28 at gcc dot gnu dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 7 Dec 2006 04:57:01 -0000
- Subject: [Bug libc/3674] New: strtod trailing zero removal doesn't allow for hex floats
- Reply-to: sourceware-bugzilla at sourceware dot org
The strtod removal of trailing 0s from the integer part with a negative exponent
doesn't adjust the exponent correctly (by 4) for each 0 removed from a hex number.
if (dig_no == int_no && dig_no > 0 && exponent < 0)
do
{
while (! (base == 16 ? ISXDIGIT (expp[-1]) : ISDIGIT (expp[-1])))
--expp;
if (expp[-1] != L_('0'))
break;
--expp;
--dig_no;
--int_no;
++exponent;
}
while (dig_no > 0 && exponent < 0);
Testcase:
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
printf("%g\n", atof("0x10p-1"));
return 0;
}
prints 1 but should print 8.
--
Summary: strtod trailing zero removal doesn't allow for hex
floats
Product: glibc
Version: 2.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: jsm28 at gcc dot gnu dot org
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=3674
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.