BigDecimal amountSumTemp = new BigDecimal(0);
amountSumTemp = amountSumTemp.add(new BigDecimal(Double.toString(amount.getAmount())));
参考:
BigDecimal num5 = new BigDecimal(2.225667);
//会损失经度,打印结果:2.225667000000000061987748267711140215396881103515625
System.out.println(num5);
应该改为写法:
BigDecimal num5 = new BigDecimal("2.225667");
或者不是double类型的也可以,例如:
BigDecimal num2 = new BigDecimal(2);//这种写法是可以的