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 <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1869>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to