[issue4707] round() shows undocumented behaviour
Mark Dickinson
report at bugs.python.org
Sat Dec 20 21:07:03 CET 2008
Mark Dickinson <dickinsm at gmail.com> added the comment:
> Is your guess for round(25.0,
> -1)==30.0 that 25.0*(1/10.0) is slightly more than 2.5 on some
> systems?
Yes, something like that. I don't think it's feasible to make round
perfectly correct (for floats) in all cases without implementing some
amount of multiple precision code. But I think we can and should
rewrite the code in such a way that it has a pretty good chance of
returning correct results in common cases. Small powers of 10 can be
computed exactly (up to 10**22, I think), in contrast to reciprocals of
powers of 10.
I'll work up a patch for round(int, int) -> int, so that at least we
have
the option of fixing this for 3.0.1 *if* there's general agreement that
that's the right way to go. Seems like a python-dev discussion might be
necessary to determine that.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4707>
_______________________________________
More information about the Python-bugs-list
mailing list