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/4943] Inconsistent rounding behaviour for sprintf and IEEE doubles


------- Additional Comments From vincent+libc at vinc17 dot org  2007-10-03 15:26 -------
(In reply to comment #41)
> Hint: "Paragraph 2: Conversions involving IEC 60559 formats follow all
> pertinent recommended practice. In particular, conversion between any
> supported IEC 60559 format and decimal with DECIMAL_DIG or fewer significant
> digits is correctly rounded, which assures that conversion from the widest
> supported IEC 60559 format to decimal with DECIMAL_DIG digits and back is the
> identity function."

I agree with that. But note that this paragraph says that:
    base 2 -> base 10 -> base 2
must be the identity function. Of course, this doesn't apply to:
    base 10 -> base 2 -> base 10

> x = 9.074439913906690
> printf("%.15f", x);
>   9.074439913906691

This is a "base 10 -> base 2 -> base 10" conversion sequence.

If you want "base 10 -> base 2 -> base 10" to be the identity function, you
shouldn't use more than 15 significant decimal digits. In your example above,
you have 16 significant digits.

-- 


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

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