[issue1565] round(x,y) doesn't behave as expected, round error

Amaury Forgeot d'Arc report at bugs.python.org
Fri Dec 7 11:13:48 CET 2007

Amaury Forgeot d'Arc added the comment:

Your function is not better:

>>> print my_round(s,2)
>>> my_round(s,2)

print uses str(), and restricts itself to 12 significant digits.
the direct call uses repr(), and display the most precise number.

The problem is not in the computation, but is inherent to the 'float'
type which cannot represent 1.41 exactly. Please carefully read the faq
entry above.

Tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list