According to the documentation BigDecimal
will throw an ArithmeticException
when the result is a non-terminating decimal. You need to specify the rounding mode:
leftVal.divide(rightVal,BigDecimal.HALF_UP);
If you want to round it to more decimals you can use setScale(numDecimals)
before doing the division.