This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/5044] printf doesn't take the rounding mode into account
- From: "sjmunroe at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 18 Apr 2008 22:04:01 -0000
- Subject: [Bug libc/5044] printf doesn't take the rounding mode into account
- References: <20070919134419.5044.vincent+libc@vinc17.org>
- Reply-to: sourceware-bugzilla at sourceware dot 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.