0
double number = 10 * 10/11;
System.out.println("Number->" + number);

Why the result is 9.0.. I am not sure why Java round up the result??

Questw
  • 43
  • 4
  • *FYI:* Although the spacing makes the expression look like it calculates as `10 * (10/11)`, it actually calculates as `(10 * 10) / 11`. That's good, because the result of the former would be `0.0`, because **integer division** of `10/11` is 0, and `10 * 0` is 0. Instead you get **integer division** of `100 / 11`, which is 9. See links up top for why and how to fix. – Andreas Aug 24 '20 at 12:34

0 Answers0