What use is the division operator on a scala BigDecimal
?
val d1 = BigDecimal(2)
val d2 = BigDecimal(3)
val div = d1 / d2 //throws ArithmeticException: non-terminating decimal expansion
In order to get this to work, you need to define a DECIMAL128
context on the decimals. Unfortunately the only way I can see of doing this is:
val div = new BigDecimal(d1.bigDecimal.divide(d2.bigDecimal, MathContext.DECIMAL128)) //OK!
But this is just a mess! Am I missing something?