I have code like this :
int a = 629339;
int b = 4096;
long res = a*b;
The result is -1717194752
but if I add one manual cast to long long res = ((long)a)*b; or long res = (long) a*b; the result is correct 2577772544
Who can explain how does it works.
a*bwill be treated as integer unless you add ‘l’ at end (or) cast.As per java tutorial