Can anyone explain logic for the output by this code ?

Why Output is 10 9 why not 10 10 ----http://ideone.com/u6q0MH

because the data type of variable xx is Double so its display the value in decimal and LL has been define as int ,Long so its display the value in Integer format.

Since you took xx as double, for your inputs the value of xx would become 9.999999… since explicitly casting it to 9 is done in the following statements, the value truncates to 9.

Hence the output is 10 9.

Just remove (LL) from the print statement and you will get the answer.

1 Like