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: Incorrect answer when using round()
Type: Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: MeeranRizvi, zach.ware
Priority: normal Keywords:

Created on 2019-03-14 14:36 by MeeranRizvi, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg337921 - (view) Author: MeeranRizvi (MeeranRizvi) Date: 2019-03-14 14:36
When using round() for calculation it gives the incorrect answer.

For Example:
round(1.5)
>>2(Which is correct)

But when we calculate:
round(2.5)
>>2(Should give 3 right?)
msg337924 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-03-14 14:40
Thanks for submitting a report MeeranRizvi.

This is the expected behavior, according to the IEEE 754 Python round to nearest even integer. This is called the bankers' rounding and is done (I think) to limitate the propagation of errors.

I suggest we close this as not a bug.
msg337925 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2019-03-14 14:44
Please see the documentation for `round`, it explains this: https://docs.python.org/3/library/functions.html#round
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80469
2019-03-14 14:44:39zach.waresetcomponents: - Build
2019-03-14 14:44:13zach.waresetstatus: open -> closed
nosy: + zach.ware, - remi.lapeyre
messages: + msg337925

type: behavior ->
resolution: not a bug
stage: resolved
2019-03-14 14:40:39remi.lapeyresettype: behavior

messages: + msg337924
nosy: + remi.lapeyre
2019-03-14 14:36:08MeeranRizvicreate