Relative Content

Tag Archive for javaprecisionbigdecimal

BigDecimal Rounding mode HALF_EVEN not working when no of digits being dropped are greater than 1

I am unable to understand the behavior of BigDecimal Roundingmode HALF_EVEN when no of digits being dropped are greater than 2(non zero).
As per docs , with HALF_EVEN rounding, when left side digit to the dropped is even, it is HALF_DOWN case so left side digit is not incremented. So “1.3651” with scale 2 should result in “1.36” but result is “1.37”. Looking at BigDecimal code, It seems if number formed by digits being dropped is greater than 50, it adds an increment and thats why I am getting the result as “1.37”.