1,截图:
2,代码:
BigDecimal unittimecost=firstnum.divide(new BigDecimal(list.get(i).get("empcounts").toString()))
3,分析:
在除法中,因为没有精确精度,所以无法取值,例如1/3=0.333333333333333…
4,解决:
添加精度范围
firstnum.divide(new BigDecimal(list.get(i).get("empcounts").toString()),4, BigDecimal.ROUND_HALF_UP)
5,参考:
6,链接:
6.1,出现 Non-terminating decimal expansion; no exact representable decimal result 问题的解决方法