我在项目中使用BigDecimal的divide方法进行除法运算时,抛出异常:
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
原因:除法的结果是一个无限循环小数,因此需要对其进行取舍的操作。
解决方法:
https://blog.csdn.net/well386/article/details/53945796?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-53945796-blog-43986703.pc_relevant_layerdownloadsortv1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-53945796-blog-43986703.pc_relevant_layerdownloadsortv1&utm_relevant_index=3