[issue1869] Builtin round function is sometimes inaccurate for floats
Mark Dickinson
report at bugs.python.org
Sat Jan 19 02:04:26 CET 2008
New submission from Mark Dickinson:
The documentation for the builtin round(x, n) says:
"Values are rounded to the closest multiple of 10 to the power minus n."
This isn't always true; for example:
Python 2.6a0 (trunk:59634M, Dec 31 2007, 17:27:56)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> round(562949953421312.5, 1)
562949953421312.62
Here 562949953421312.5 is exactly representable as an IEEE754 double, so the output from the round function should be
exactly the same as the input.
Assigning this to myself to remind me to try to fix it someday.
----------
assignee: marketdickinson
messages: 60129
nosy: marketdickinson
priority: low
severity: minor
status: open
title: Builtin round function is sometimes inaccurate for floats
type: behavior
versions: Python 2.5, Python 2.6, Python 3.0
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1869>
__________________________________
More information about the Python-bugs-list
mailing list