The problem is when I was multiplying two BigDecimal
numbers I got a big result. After that I used setScale(2, HalfDown)
but did not get the desired result.
The wrong result
"2.89500004313886165618896484375".setScale(2, BigDecimal.ROUND_HALF_DOWN);
I need 2.89 and the wrong result was 2.90
Using .round(new MathContext(2))
I got it :
"2.89500004313886165618896484375".round(new MathContext(2));
The right result is 2.89