[issue9885] Function Round does not work properly in some conditions

R. David Murray report at bugs.python.org
Fri Sep 17 16:28:00 CEST 2010


R. David Murray <rdmurray at bitdance.com> added the comment:

Please read

    http://docs.python.org/tutorial/floatingpoint.html

Although your case isn't directly covered there, the root cause is the same.  Floating point can't exactly represent 10.3.

Note that in Python2.7 and 3.x, the repr will be shortened to 10.3, so if you'd tried this there you would never have noticed the underlying issue.

If you need exact decimal arithmetic, use the Decimal module.

----------
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9885>
_______________________________________


More information about the Python-bugs-list mailing list