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/5044] printf doesn't take the rounding mode into account


------- 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.


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