public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sjmunroe at us dot ibm dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/5044] printf doesn't take the rounding mode into account
Date: Sat, 19 Apr 2008 00:08:00 -0000	[thread overview]
Message-ID: <20080418220401.14170.qmail@sourceware.org> (raw)
In-Reply-To: <20070919134419.5044.vincent+libc@vinc17.org>


------- Additional Comments From sjmunroe at us dot ibm dot com  2008-04-18 22:03 -------
the core problem is that you are trying to apply decimal rounding rules to
IEEE754 Binary float.

For example 0.5001 is really 0x1.000d1b71758e20p-1 (format %.14a which shows the
mantisa in hex). Note that there is no exact binary representation for rounding
value 0.005 implied by this request.

To get what Vincent says he wants would require converting the IEEE754 double to
decimal and perform the rounding in decimal (via quantize). It is is not clear
that The ISO C standard says in 7.19.6.1#13 requires this:

"Otherwise, the source value is bounded by two adjacent decimal strings L < U,
both having DECIMAL_DIG significant digits; the value of the resultant decimal
string D should satisfy L <= D <= U, with the extra stipulation that the error
should have a correct sign for the current rounding direction."

This implies that either L or U (.50 or .51) are allowed!

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


  parent reply	other threads:[~2008-04-19  0:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 13:44 [Bug libc/5044] New: " vincent+libc at vinc17 dot org
2008-04-15 21:52 ` [Bug libc/5044] " eberlein at us dot ibm dot com
2008-04-15 22:54 ` vincent+libc at vinc17 dot org
2008-04-16 14:21 ` rsa at us dot ibm dot com
2008-04-16 14:21 ` rsa at us dot ibm dot com
2008-04-16 14:21 ` rsa at us dot ibm dot com
2008-04-17 20:28 ` eberlein at us dot ibm dot com
2008-04-17 20:34 ` eberlein at us dot ibm dot com
2008-04-17 23:21 ` vincent+libc at vinc17 dot org
2008-04-17 23:42 ` eberlein at us dot ibm dot com
2008-04-18  7:34 ` vincent+libc at vinc17 dot org
2008-04-18 21:28 ` eberlein at us dot ibm dot com
2008-04-18 23:58 ` vincent+libc at vinc17 dot org
2008-04-19  0:08 ` sjmunroe at us dot ibm dot com [this message]
2008-06-05 17:53 ` khalil dot ghorbal at cea dot fr

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=20080418220401.14170.qmail@sourceware.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).