public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/6467] New: strtod "0.0" returns nonzero
@ 2008-04-29 18:00 eberlein at us dot ibm dot com
  2008-04-29 18:49 ` [Bug libc/6467] " jakub at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eberlein at us dot ibm dot com @ 2008-04-29 18:00 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/6467] strtod "0.0" returns nonzero
  2008-04-29 18:00 [Bug libc/6467] New: strtod "0.0" returns nonzero eberlein at us dot ibm dot com
@ 2008-04-29 18:49 ` jakub at redhat dot com
  2008-04-29 19:30 ` eberlein at us dot ibm dot com
  2008-04-29 19:44 ` jakub at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at redhat dot com @ 2008-04-29 18:49 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-04-29 18:48 -------
It would be helpful if you could say on which target that is, because I
definitely can't reproduce it, neither on x86_64, nor on ppc32.

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>

int
main (void)
{
  printf("%g\n", strtof("0.0", NULL));
  printf("%g\n", strtod("0.0", NULL));
  printf("%Lg\n", strtold("0.0", NULL));
  printf("%g\n", strtof("0", NULL));
  printf("%g\n", strtod("0", NULL));
  printf("%Lg\n", strtold("0", NULL));
  printf("%g\n", strtof("0.000", NULL));
  printf("%g\n", strtod("0.000", NULL));
  printf("%Lg\n", strtold("0.000", NULL));
  printf("%g\n", strtof("0.000e0", NULL));
  printf("%g\n", strtod("0.000e0", NULL));
  printf("%Lg\n", strtold("0.000e0", NULL));
  return 0;
}

prints just 0s.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/6467] strtod "0.0" returns nonzero
  2008-04-29 18:00 [Bug libc/6467] New: strtod "0.0" returns nonzero eberlein at us dot ibm dot com
  2008-04-29 18:49 ` [Bug libc/6467] " jakub at redhat dot com
@ 2008-04-29 19:30 ` eberlein at us dot ibm dot com
  2008-04-29 19:44 ` jakub at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: eberlein at us dot ibm dot com @ 2008-04-29 19:30 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From eberlein at us dot ibm dot com  2008-04-29 19:29 -------
Bah, close this due to user error.  I neglected to include stdlib.h.

Aside: I discovered the problem reading the null terminator while working on the
dfp version and assumed it affected the bfp version as well.  It looks like
str_to_mpn isn't affected by the null so it just works.

-- 


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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/6467] strtod "0.0" returns nonzero
  2008-04-29 18:00 [Bug libc/6467] New: strtod "0.0" returns nonzero eberlein at us dot ibm dot com
  2008-04-29 18:49 ` [Bug libc/6467] " jakub at redhat dot com
  2008-04-29 19:30 ` eberlein at us dot ibm dot com
@ 2008-04-29 19:44 ` jakub at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at redhat dot com @ 2008-04-29 19:44 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-04-29 19:43 -------
Invalid.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-29 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-29 18:00 [Bug libc/6467] New: strtod "0.0" returns nonzero eberlein at us dot ibm dot com
2008-04-29 18:49 ` [Bug libc/6467] " jakub at redhat dot com
2008-04-29 19:30 ` eberlein at us dot ibm dot com
2008-04-29 19:44 ` jakub at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).