[Bug libc/14049] New: Incorrect strtod, atof etc. hex float rounding

jsm28 at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Wed May 2 15:48:00 GMT 2012


http://sourceware.org/bugzilla/show_bug.cgi?id=14049

             Bug #: 14049
           Summary: Incorrect strtod, atof etc. hex float rounding
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


strtod, atof and related functions always treat hex floats half way between two
representable values as rounding away from zero, instead of round-to-even. 
Testcase:

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

int
main (void)
{
  printf ("%.16A %.16A\n", 0x10000000000000800p0, atof
("0x10000000000000800p0"));
  return 0;
}

Prints:

0X1.0000000000000000P+64 0X1.0000000000001000P+64

This is different from bug 3479, which concerns strtod rounding for decimal
numbers.

I'm testing a patch.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the Glibc-bugs mailing list