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: Bug of round function
Type: performance Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, Narek2018, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-12-31 08:10 by Narek2018, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
main.py Narek2018, 2020-12-31 08:10 example
Messages (3)
msg384101 - (view) Author: Narek (Narek2018) Date: 2020-12-31 08:10
The my code is folowing

for i in range(1, 5):
    a = i + 0.5
    b = round(a)
    print(a, "rounded as =>", b)

output is

1.5 => 2
2.5 => 2
3.5 => 4
4.5 => 4

the rounding is not correct in output
msg384102 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2020-12-31 08:45
This is not a bug. See https://stackoverflow.com/a/10825998/11461120
msg384103 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-31 09:00
It works as documented. https://docs.python.org/3/library/functions.html#round
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86959
2020-12-31 09:00:22serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg384103

resolution: not a bug
stage: resolved
2020-12-31 08:45:06Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg384102
2020-12-31 08:10:49Narek2018create