Non-terminating decimal expansion; no exact representable decimal result。

使用 Bigdecimal 做除法,除不尽时 JDK1.7 会报错、

Non-terminating decimal expansion; no exact representable decimal result

JDK1.8 以上会产生一个空值

解决办法保留两位向上取整 xxx.divide(bar, 2, BigDecimal.ROUND_HALF_UP);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章