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() doesn't work correctly in 3.1.1
Type: behavior Stage:
Components: Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bkovt, mark.dickinson, tim.peters
Priority: normal Keywords:

Created on 2010-01-04 01:59 by bkovt, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg97186 - (view) Author: (bkovt) Date: 2010-01-04 01:59
round(125, -1) produces 120 in Python 3.1.1. It produces 130.0 in 2.6.4.
msg97190 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2010-01-04 02:58
Note that round() is implemented much more carefully in Python 3.x than in Python 2.x, and 120 is actually the correct result under nearest/even rounding (125 is exactly halfway between representable values when rounded to the closest 10, and nearest/even rounding resolves the ambiguity by picking the closest value whose last relevant digit is even).
msg97191 - (view) Author: (bkovt) Date: 2010-01-04 03:29
All right, round() in 3.1 uses 'Round half to even' instead of 'Round half up'. In fact, now I can see this clearly explained in 3.1 documentation. Thanks for the quick reply and sorry for the erroneous bug entry!
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51877
2010-01-04 03:31:45benjamin.petersonsetstatus: open -> closed
resolution: not a bug
2010-01-04 03:29:21bkovtsetmessages: + msg97191
2010-01-04 02:58:15tim.peterssetnosy: + tim.peters
messages: + msg97190
2010-01-04 02:50:06r.david.murraysetnosy: + mark.dickinson
2010-01-04 01:59:24bkovtcreate