【异常】java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.

Abnormal: not specified accuracy of the data leads to operational data can not be properly settled

The implementation of the following division:

int value = BigDecimal.valueOf(211111).divide(BigDecimal.valueOf(3)).intValue();

Accuracy is specified after it:

int value = BigDecimal.valueOf(210000).divide(BigDecimal.valueOf(3), 2, BigDecimal.ROUND_HALF_UP).intValue();

Guess you like

Origin www.cnblogs.com/756623607-zhang/p/11755747.html