How come -20 % 3 = 1
?
Just confused with the formulae used for negative number % positive number.
(I have seen many question related in quora but still not clear with formula used)
How come -20 % 3 = 1
?
Just confused with the formulae used for negative number % positive number.
(I have seen many question related in quora but still not clear with formula used)
I am not sure about the formula but you can add x to the negative number such that (x+ negative number)>=0
and x
is a multiple of mod value . This is right because
x % k = (x+ y*k) % k