天天看点

使用BigDecimal报的错

错误:java.lang.arithmeticexception: non-terminating decimal expansion; no exact representa  小数位膨胀 

解决方法:(截取相应的位数)

  1. BigDecimal result = x.divide(y, 3, BigDecimal.ROUND_HALF_UP)