正常情況下直接使用 BigDecimal stripTrailingZeros()方式即可,但是,當數值等於0時,方法不再生效。原因在於其內部作了判斷
if (isZero()) {
// Preserve RI compatibility, so BigDecimal.equals (which checks
// value *and* scale) continues to work.
return this;
}
2020-02-19