I want to round BigDecimal value to the nearest integer.
I tried to used solution from this issue Java BigDecimal: Round to the nearest whole value , but it doesn't work for me.
BigDecimal scaled = value.setScale(0, RoundingMode.HALF_UP);
System.out.println(value + " -> " + scaled);
It works right in case such:
100.12 -> 100.00
100.44 -> 100.00
100.50 -> 101.00
100.75 -> 101.00
But it failed in case
100.47 -> 100 instead of 101.
Why this code doesn't work?