up previous next
mod --
remainder for integers
|
We define the quotient
Q
and remainder
R
to be integers which
satisfy
N = Q*D + R where the quotient
Q
is
rounded
towards zero, so the
remainder is zero or has the same sign as
N
.
mod(N, D)
returns
R
, while
div(N, D)
returns
Q
.
NOTE: To perform the division algorithm on a polynomial, use
NR
(normal remainder) to find the remainder, or
DivAlg
to get both the quotients and the remainder.
/**/ mod(10,3);
1
/**/ mod(-10,3);
-1
/**/ A:=10; B:=-5;
/**/ mod(A-B,3) = 0; // Test if A and B are equiv mod 3
true
/**/ mod(A,3) = mod(B,3); // WRONG!! Do not do this!
false
|