[Python-Dev] Change in Python 3's "round" behavior

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Sep 30 17:50:36 EDT 2018

Alex Walters wrote:
> Other use case is finance, where you can end up with interest calculations
> that are fractional of the base unit of currency.  US$2.345 is impossible to
> represent in real currency, so it has to be rounded.

This brings us back to my original point about floating point
accuracy. If you do your interest calculation in floating
point binary, first it's very unlikely that it will come
out ending in exactly 0.5 of a cent, and secondly if you
care about the details that much, you should be calculating
in decimal, and being explicit about exactly what kind of
rounding you're doing.


More information about the Python-Dev mailing list