4 Answers
New Answerhttps://stackoverflow.com/questions/7594508/modulo-operator-with-negative-values "... the binary % operator yields the remainder from the division of the first expression by the second ... if the quotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a... " Rearranging the equation, a%b can be defined as f(a,b) = a - (a/b)*b For the case of a = -6 and b = 4, f(-6,4) = -6 - (-6/4)*4 => -6 - (-1)*4 = -6 + 4 = -2
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message