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.

Author MrBlueSkies
Recipients MrBlueSkies
Date 2021-04-21.08:15:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618992902.95.0.267811041395.issue43903@roundup.psfhosted.org>
In-reply-to
Content
When rounding numbers with round(), middle values at with even base number are rounded in wrong direction.

Python 3.9.1 (default, Feb  3 2021, 07:38:02) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin

MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)
macOS 11.2.3 (20D91), Darwin 20.3.0

to reproduce (wrong results marked with "*"):

floats:

>>> for i in range(0, 10):
...     i /= 2
...     print(i, '->', round(i))
... 
0.0 -> 0
0.5 -> 0 *
1.0 -> 1
1.5 -> 2
2.0 -> 2
2.5 -> 2 *
3.0 -> 3
3.5 -> 4
4.0 -> 4
4.5 -> 4 *

and for ints:

>>> for i in range(50, 1000, 50):
...     print(i, '->', round(int(i), -2))
... 
50 -> 0 *
100 -> 100
150 -> 200
200 -> 200
250 -> 200 *
300 -> 300
350 -> 400
400 -> 400
450 -> 400 *
500 -> 500
550 -> 600
600 -> 600
650 -> 600 *
700 -> 700
750 -> 800
800 -> 800
850 -> 800 *
900 -> 900
950 -> 1000
History
Date User Action Args
2021-04-21 08:15:02MrBlueSkiessetrecipients: + MrBlueSkies
2021-04-21 08:15:02MrBlueSkiessetmessageid: <1618992902.95.0.267811041395.issue43903@roundup.psfhosted.org>
2021-04-21 08:15:02MrBlueSkieslinkissue43903 messages
2021-04-21 08:15:02MrBlueSkiescreate