Never really thought about it before, if I offhand look at -14%3 and 14%-3, I would have guessed the result to be the same in both cases...but it is -2 in the first case and 2 in the second case.
the rule is a = (a/b)*b + a%b,
(-14) = (-4)*( 3) + (-14)%3
( 14) = (-4)*(-3) + ( 14)%3
No comments:
Post a Comment