[issue1559] round() does not
Georg Brandl
report at bugs.python.org
Wed Dec 5 22:09:25 CET 2007
Georg Brandl added the comment:
round() does not return a string, but a floating point number, the best
approximation to the "real" result that is achievable with the limited
precision of binary floating point.
That result is then formatted to a string for display by the interactive
interpreter using the repr() function, which formats a float with (I
think) 17 decimal digits.
So, the point here is that repr() produces "too many" digits for your
liking ;) You can use str() to cut off at fewer digits, which will
produce the "correct" string in most cases.
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1559>
__________________________________
More information about the Python-bugs-list
mailing list