Python - Ridiculous Rounding

发布时间 2023-06-28 15:41:04作者: ZhangZhihuiAAA

 

Python 3 uses “Banker’s Rounding” which is defined like this: “Exact halfway cases are now rounded to the nearest even result instead of away from zero” - per What’s new in Python 3 .
In the case of 1.5, Python rounds to two because that is the nearest even result. If you apply that logic to 2.5, the nearest even value is also two!