Home > Back-end >  Float precision loss problem
Float precision loss problem

Time:12-11

 
//1011000100110010110110.0100110011001100 2903222.29998779296875
//1011000100110010110110.0100111101011100 2903222.30999755859375
Float f1=2903222.3 F;
Float f2=2903222.31 F;
System. The out. Println (f1);
System. The out. Println (f2);
System. The out. Println (F=2903222.3=2903222.31 F);


As the appeal: why are both output shows 2903222.2, rather than 2903222.299999999999999

CodePudding user response:

So still need to use BigDecimal

CodePudding user response:

Single precision floating point there are six more (decimal) the accuracy of the theory of error range
  • Related