Decimal ROUND_HALF_EVEN Default
tim.peters at gmail.com
Tue Jan 17 15:48:58 CET 2006
> If 'bankers rounding' is HALF_ROUND_EVEN, what is HALF_ROUND_UP?
Not banker's rounding ;-). Same answer if you had said ROUND_HALF_UP
instead (which I assume you intended) -- most of these don't have
> I confess to never having heard the terms.
ROUND_HALF_UP etc are symbolic constants in Python's `decimal` module;
see the docs.
> I usually do: Y = int(X + 0.5) scaled to proper # of decimal places.
> Which type of rounding is this? If either.
If you meant what you said, it's not "rounding" at all, because it's
insane for negative inputs. For example, int(-2 + 0.5) = int(-1.5) =
-1, and no _rounding_ method changes an exact integer (like -2) to a
_different_ exact integer (like -1).
If you were assuming X >= 0.0, then int(X+0.5) coincides with
ROUND_HALF_UP on that domain. For X < 0.0, ROUND_HALF_UP works like
More information about the Python-list