I searched and found topics relating to this issue but in all of them here the reason was overflow (the result was too big for an int type,right?). but in this case the result is less than the max value for int and still produces a negative number from 2 positives. and I wonder why.
heres the code:
int s = (50*49*48*47*46*45);
out.println(s);
OUTPUT:
-1443597888
now when i try 449 instead of 49:
int s = (50*449*48*47*46*45);
out.println(s);
OUTPUT:
1760488896
so why does that happen? I generally want to calculate (50*49*48*47*46*45)/(1*2*3*4*5*6) but it keeps giving negative result.
Thanks for the help.
Oh Yeah I am using Java, a very early beginner so I have little clue of whats going on. thanks.