Possible Duplicate:
ArithmeticException thrown during BigDecimal.divide
This results in ArithmeticException: http://ideone.com/RXeZw
Providing a scale and rounding mode will give me the wrong result. This example should output 50.03%. How to round this correctly?
For easier reference, this is the code:
BigDecimal priceDiff = BigDecimal.ONE
.subtract(new BigDecimal(9.99)
.divide(new BigDecimal(19.99)))
.multiply(new BigDecimal(100));
System.out.println(priceDiff.toPlainString());