下面的代码作用:
a=0.00001234
保留完之后,结果为0.000012
double a = 0.00001234; BigDecimal b = new BigDecimal(String.valueOf(a)); BigDecimal divisor = BigDecimal.ONE; MathContext mc = new MathContext(2); System.out.println(b.divide(divisor, mc));
double a = 0.00001234; BigDecimal b = new BigDecimal(String.valueOf(a)); BigDecimal divisor = BigDecimal.ONE; MathContext mc = new MathContext(2); System.out.println(b.divide(divisor, mc));