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

BigDecimal调用divide()方法时报异常: Non-terminating decimal expansion; no exact representable decimal result.
原因是出现了无限小数,这时候需要定义保留几位小数,
decemal1.divide(decimal2, 6, BigDecimal.ROUND_HALF_UP);

posted @ 2021-09-07 15:02  JAVA开发老菜鸟  阅读(2736)  评论(0编辑  收藏  举报