0

Can anyone explain what's going on here? My calculator insists that the result of equitation is 13201.

double test = 132.01/0.01D;
System.out.println(test); <- 13200.999999999998

Probably, this is very simple question, but I really don't understand. Most of questions in SO on similar topic involves Integer and Double.

J. Doe
  • 13
  • 4
  • 1
    See http://stackoverflow.com/q/588004/5320080 – Petterson Mar 16 '17 at 07:30
  • Use strictfp please. – Grim Mar 16 '17 at 07:32
  • you can always use setRoundingMode with DecimalFormat if you want to format it: http://stackoverflow.com/questions/40306355/java-convert-a-format-string – NewBie1234 Mar 16 '17 at 07:33
  • Double division is replaced during compile time itself. Also if you try to print 132.01 direclty then look into class file,the value is actually 132.00999999999999D which should explain why you got your answer... You can use Jade decompiler for the same – dvsakgec Mar 16 '17 at 07:36
  • There's nothing wrong; this is how IEEE floating point numbers work. – duffymo Mar 16 '17 at 08:55

0 Answers0