Mod
From Free Pascal wiki
Jump to navigationJump to search
Mod (modulus) divides two numbers and returns only the remainder that is a whole number. For instance, the expression "a:= 13 mod 4;" would evaluate to 1 (a=1), while "b := 12 mod 4;" would evaluate to 0 (b=0).
From the language reference:
- The sign of the result of a Mod operator is the same as the sign of the left side operand of the Mod operator. In fact, the Mod operator is equivalent to the following operation :
I mod J = I - (I div J) * J
For example "c := -13 mod 4;" results in c = -1.