标签:ring ros color back bsp 解决 lin java round
Java有自带的 stripTrailingZeros() 方法用于去除末尾多余的0
BigDecimal num = new BigDecimal("100.1000"); BigDecimal numNoEndZero = num.stripTrailingZeros(); //numNoEndZero :1E+2 System.out.println(numNoEndZero.toString());
按上面的方法输出结果,会显示科学计数法,所以需要处理一下,解决方法:
String numNoEndZeroStr = new BigDecimal("100.1000").stripTrailingZeros().toPlainString(); //numNoEndZeroStr :100.1 System.out.println(numNoEndZeroStr);
标签:ring ros color back bsp 解决 lin java round
原文地址:https://www.cnblogs.com/zjfjava/p/9931895.html