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

今天干活跑别人接口的时候遇到一个报错,记录一下

这个错误一般出现在BigDecimal的除法运算中,如:

 //像这样不做小数位数处理的话就有可能会报错
BigDecimal result= num1.divide(num2);

正确的:
//设置了保留几位,这里是两位✔
BigDecimal result= num1.divide(num2,2);

一定要设置保留几位!!!!!!!!

BigDecimal的除法运算 报错 Non-terminating decimal expansion; no exact representable decimal result.

相关文章:

  • 2022-12-23
  • 2021-11-03
  • 2021-05-31
  • 2022-01-08
  • 2021-06-07
  • 2021-07-30
  • 2021-12-04
猜你喜欢
  • 2022-01-14
  • 2021-12-04
  • 2022-12-23
  • 2021-08-18
  • 2021-11-28
  • 2021-06-01
相关资源
相似解决方案