+ 1

[HELP]Modulus Operator Workings

How does the modulus operator work on a math perspective. Also how is that math different on the computer

2nd May 2017, 2:24 PM
Martin Brock
Martin Brock - avatar
2 odpowiedzi
+ 4
% (Modulo) means the remainder of the quotient, Math isn't different from computers to real life, maybe it wasn't teached
2nd May 2017, 3:18 PM
Complex
Complex - avatar
+ 2
In mathematics you'd have a definition/proposition like this: Given two integers a,d, where d is not zero, there are unique integers q,r, such that a = qd + r and 0≤r<abs(d). Then a%d is defined to be r. Of course you'd have to proof existence and uniqueness of r and q, to be sure r is well defined this way. This result/idea generalises, but I'm not going to go into details there. If you are only dealing with ints, the modulus is consistent with the mathematical version.
2nd May 2017, 3:23 PM
Tob
Tob - avatar