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);

 

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