What is the scala split operator used for BigDecimal?
val d1 = BigDecimal(2)
val d2 = BigDecimal(3)
val div = d1 / d2 //throws ArithmeticException: non-terminating decimal expansion
For this to work, you need to define the context DECIMAL128for the decimal places. Unfortunately, the only way to do this is:
val div = new BigDecimal(d1.bigDecimal.divide(d2.bigDecimal, MathContext.DECIMAL128))
But this is just a mess! Did I miss something?
source
share