// Reason 16 decimals ->> Output: 11
double num1 = 10.9999999999999999;
Integer res1 = (int) Math.floor(num1);
System.out.println(res1);
// Reason 15 decimals ->> Output: 10
double num2 = 10.999999999999999;
Integer res2 = (int) Math.floor(num2);
System.out.println(res2);
// Can you get 10 in both cases?
Anonymous #11493846
Level 3
Why does this happen in Java? With two equal numbers
Comments
- Popular
- New
- Old
You must be signed in to leave a comment
This page doesn't have any comments yet