Have a look at the following code snippet
What would you expect?
Instead of printing “100000000000000″ , it prints “276447232″ on my machine.
This is because the arithmetic is performed as integer before assigning the value to result variable.
To get the correct result, just make one of the operands as long
The above is a simple example. But this could possibly happen in real life. Some time we just perform arithmetic on integer variables and unknowingly hits the overflow error.