This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: round(x) gives wrong result for large odd integers
Type: behavior Stage: needs patch
Components: Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson
Priority: high Keywords: easy

Created on 2009-10-06 08:38 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg93635 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-06 08:38
The single-argument form of the builtin round function can give
incorrect results for large integers.

>>> x = 5e15+1
>>> x == int(x)
True
>>> x == round(x)  # expect True here
False
>>> x
5000000000000001.0
>>> round(x)
5000000000000002.0
>>> int(x)
5000000000000001

This is already fixed in trunk (and in 3.x);  the fix needs to be
backported to release26-maint.
msg95091 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-11-09 17:46
Fixed in r76179.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51319
2009-11-09 17:46:04mark.dickinsonsetstatus: open -> closed
resolution: fixed
messages: + msg95091
2009-10-06 08:38:44mark.dickinsoncreate