<<< RoundingMode.HALF_UP | Index | BigDecimal Rounding Demo >>> |
This rounding mode is analogous to the rounding policy used for float and double arithmetic in Java.
Same as RoundingMode.HALF_UP, except when the rounding digit is 5:
it will round down if the digit to the left of the 5 is even
it will round up if the digit to the left of the 5 is odd
For example, after
BigDecimal bdHalfEven = bdValue.setScale(0, RoundingMode.HALF_EVEN);
the rounding will be
Input Rounded value ----- ------------- 2.5 -> 2 // because 2 is even, round down 7.5 -> 8 // because 7 is odd, round up
<<< RoundingMode.HALF_UP | Index | BigDecimal Rounding Demo >>> |