This is indeed clearly documented [1], I guess I never looked closely enough. I found some discussion on the dev-python list [2] which shows at least I'm not the only one surprised by this!
This is indeed clearly documented [1], I guess I never looked closely enough. I found some discussion on the dev-python list [2] which shows at least I'm not the only one surprised by this!
That… is exactly the behaviour python implements, and what GP was surprised by…
It is also, incidentally, the IEEE 754 recommendation.
Python 2 used to round away from 0.
> But I know the regulator will expect round(0.5) = 1, not 0.
That's not necessarily the most helpful, as there's at least two tie-breakings which provide that, but differ in their treatment of negative numbers (round up or round to +∞, and round away from zero or round to ∞).
So, consider the source of the complaint.
Well that and it returns an integer when rounding to 0 digits, but that’s less of an issue since the langage also switched to “true division”.