long m = 24 * 60 * 60 * 1000 * 1000;
The above code creates overflow and doesn't print the correct result.
long m2 = 24L * 60 * 60 * 1000 * 1000;
long m3 = 24 * 60 * 60 * 1000 * 1000L;
The above 2 lines print the correct result.
My questions are-
- Does it matter to the compiler which I use,
m2
orm3
? - How does java starts multiplying? Left to right or right to left? Does 24*60 gets computed first or 1000*1000?