1、
String price = "19.90"; // 19.99
int totalFee =(int)(new BigDecimal(price).multiply(new BigDecimal("100"))).doubleValue();
int totalFee2 = (int) (Double.parseDouble(price) * 100);
System.out.println(totalFee); //1990
System.out.println(totalFee2); //1989
Double 和bigdecimal处理不一样
2、
Long l = 112630689643634688L;
18位的Long,以Long类型返回给前端,前端解析出来的值,不一致。
解决办法:
在response对象里面的Long类型的字段加个注解:

java中Long精度问题

 

 java中Long精度问题

 

 

java中Long精度问题

相关文章:

  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
相关资源
相似解决方案