Rounding mode to round towards the "nearest neighbor"
unless both neighbors are equidistant, in which case, round
towards the even neighbor. Behaves as for
RoundingMode.HALF_UP
if the digit to the left of the
discarded fraction is odd; behaves as for
RoundingMode.HALF_DOWN
if it's even. Note that this
is the rounding mode that statistically minimizes cumulative
error when applied repeatedly over a sequence of calculations.
It is sometimes known as "Banker's rounding," and is
chiefly used in the USA. This rounding mode is analogous to
the rounding policy used for float
and double
arithmetic in Java.
Example:
Input Number | Input rounded to one digit with HALF_EVEN rounding
|
---|---|
5.5 | 6 |
2.5 | 2 |
1.6 | 2 |
1.1 | 1 |
1.0 | 1 |
-1.0 | -1 |
-1.1 | -1 |
-1.6 | -2 |
-2.5 | -2 |
-5.5 | -6 |
Diagram: Context