News for hackers. Stuff that matters.
Re:Figuring out round, floor and ceil with integer division by masklinn on Saturday November 26, 2022 @03:47AM (#33751089)
> I have seen banking regulators getting upset in the past because of roundings not following the usual convention ("banker's rounding").

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.

Re:Figuring out round, floor and ceil with integer division by cm2187 on Saturday November 26, 2022 @04:08AM (#33751177)
Ok sorry, I think that's me misinterpreting what banker's rounding mean. But I know the regulator will expect round(0.5) = 1, not 0.
Re:Figuring out round, floor and ceil with integer division by masklinn on Saturday November 26, 2022 @05:47AM (#33751618)
Banker's rounding is "round to even", because it limits the amount of bias introduced by the rounding.

> 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 ∞).