This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/3674] New: strtod trailing zero removal doesn't allow for hex floats


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]