Non-terminating decimal expansion

BigDecimal除法运算报错,错误如下:
Non-terminating decimal expansion; no exact representable decimal result

 

原因是:

BigDecimal divide(BigDecimal divisor, int scale, int roundingMode)

if divisor is zero, roundingMode==ROUND_UNNECESSARY and the specified scale is insufficient to represent the result of the division exactly
所以应该指定scale和roundingMode,保证对于无限小数有足够的范围来表示结果。

你可能感兴趣的:(Mina)