[issue5118] '%.2f' % 2.545 doesn't round correctly
Ultrasick
report at bugs.python.org
Sat Jan 31 16:51:44 CET 2009
Ultrasick <python at ontheserver.de> added the comment:
Well that's not what I have learned how rounding works. I think that's
the more common way:
0.4 -> 0
0.5 -> 1
0.6 -> 1
I hope you don't try to spread the misbehavoir of pythons way of rounding
print '%.2f' % 2.545 // returns 2.54
to the built in round() function. So that round() would also return 2.54.
The result of rounding 2.545 is 2.55 no matter how python temporarly
stores "2.545" and independent of how python does the rounding. The
result is 2.55 and not 2.54. If python doesn't deliver "2.55" as the
result of it's rounding algorithm then it's doing it wrong. And if
python does stuff wrong then it has a bug.
in my opinion
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5118>
_______________________________________
More information about the Python-bugs-list
mailing list