[Bug libstdc++/49048] setprecision rounding fails in some cases
s.cecilio at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu May 19 06:22:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49048
--- Comment #4 from Cecilio <s.cecilio at gmail dot com> 2011-05-19 05:39:43 UTC ---
Ok Thank you, I will report to glbc. But, to try to learn and understand
something, could you please answer a question for me?:
My understanding is that printf truncates, so
'printf("%.2f", 5798.12500) --> 5798.12
'printf("%.2f", 5798.87500) --> 5798.87
and 'cout << setprecision(2)' rounds, so
cout << fixed << setprecision(2) << 5798.12500 --> 5798.13
cout << fixed << setprecision(2) << 5798.87500 --> 5798.88
If, internally, the implementation of 'cout << setprecision' uses printf,
somehow setprecision has to take care of rounding, as print will not.
what gcc library/component is doing the rounding? Perhaps I should report there
instead of printf.
Thank for any info on this.
More information about the Gcc-bugs
mailing list