converted to long double type

System.out.println(new Double(234314.999999999).longValue());//234314
  System.out.println(new Double(234314.9999999999).longValue());//234314
  System.out.println(new Double(234314.99999999999).longValue());//234315
  System.out.println(new Double(234314.999999999999).longValue());//234315 

 

  System.out.println((long)234314.999999999);//234314
  System.out.println((long)234314.9999999999);//234314
  System.out.println((long)234314.99999999999);//234315
  System.out.println((long)234314.999999999999);//234315

 

When the double turn long, different number of decimal places, the result may be different

Direct normal decimal rounding, decimal places may carry not less than 11 when

Guess you like

Origin www.cnblogs.com/CoderRdf/p/12206921.html