+ 2

Why this result??

double a=888/100*17; System.out.println(a); output is 136.0 Can anyone explain the result???

28th Jun 2019, 10:40 PM
Mina
2 Respuestas
+ 2
I got it....Thank you very much....
28th Jun 2019, 11:35 PM
Mina
+ 1
888, 100 and 17 are all ints. 888/100 is 8 (decimals get cut off), 8*17 is 136. This gets converted to a double and stored. To get the proper result, change one of the numbers to a double literal, for example: double a = 888.0/100+7;
28th Jun 2019, 11:26 PM
HonFu
HonFu - avatar