RoundingMode.HALF_EVEN

Rounding mode to round towards the {@literal "nearest neighbor"} unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for {@code RoundingMode.HALF_UP} if the digit to the left of the discarded fraction is odd; behaves as for {@code 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 {@literal "Banker's rounding,"} and is chiefly used in the USA. This rounding mode is analogous to the rounding policy used for {@code float} and {@code double} arithmetic in Java.

<p>Example: <table border> <caption><b>Rounding mode HALF_EVEN Examples</b></caption> <tr valign=top><th>Input Number</th> <th>Input rounded to one digit<br> with {@code HALF_EVEN} rounding <tr align=right><td>5.5</td> <td>6</td> <tr align=right><td>2.5</td> <td>2</td> <tr align=right><td>1.6</td> <td>2</td> <tr align=right><td>1.1</td> <td>1</td> <tr align=right><td>1.0</td> <td>1</td> <tr align=right><td>-1.0</td> <td>-1</td> <tr align=right><td>-1.1</td> <td>-1</td> <tr align=right><td>-1.6</td> <td>-2</td> <tr align=right><td>-2.5</td> <td>-2</td> <tr align=right><td>-5.5</td> <td>-6</td> </table>

class RoundingMode
static
RoundingMode HALF_EVEN;

Meta