public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jsm28 at gcc dot gnu dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/3674] New: strtod trailing zero removal doesn't allow for hex floats
Date: Thu, 07 Dec 2006 04:57:00 -0000	[thread overview]
Message-ID: <20061207045700.3674.jsm28@gcc.gnu.org> (raw)

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.


             reply	other threads:[~2006-12-07  4:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-07  4:57 jsm28 at gcc dot gnu dot org [this message]
2006-12-10  0:03 ` [Bug libc/3674] " drepper at redhat dot com
2007-01-12 18:07 ` cvs-commit at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061207045700.3674.jsm28@gcc.gnu.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).