Home > Back-end >  Why 100 * 1.15=114.99999999999999, jdk1.8
Why 100 * 1.15=114.99999999999999, jdk1.8

Time:12-16

CodePudding user response:

Calculation accuracy is missing, numerical computing in general, not be so direct operation you can try to do
 

BigDecimal b1=new BigDecimal (Double. ToString (10 d));
BigDecimal b2=new BigDecimal (Double. ToString (1.15 d));
System. The out. Println (b1. Multiply (b2). DoubleValue ());

CodePudding user response:

This bigdecimal can be used to calculate