Determine the remainder from a division.
MOD(num, den)
num |
- |
A scalar, series, or table. The numerator value. |
den |
- |
A scalar, series, or table. The denominator value. |
A scalar, series, or table.
mod(5,3)
returns 2.
W1: 1..10
W2: ravel(W1,5)
mod(W1,5)
returns the series: {1, 2, 3, 4, 0, 1, 2, 3, 4, 0}
mod(W2,5)
returns the 5x2 array:
{{1, 1},
{2, 2},
{3, 3},
{4, 4},
{0, 0})
mod(12.3, -3) == –2.7
rem(12.3, -3) == 0.3
mod(12.3, 0) == 12.3
mod(5.125, int(5.125))
returns 0.125.
W1: rand(5, 1) * 10
W2: mod(w1, int(w1))
Because W1 is positive, W2 contains the fractional part of W1.
mod(a, b) is equivalent to a % b
mod(a, b) has the same sign as b and rem(a, b) has the same sign as a. Both are equal if the inputs have the same sign, but differ by b if the signs differ, i.e.:
mod(-a, b) == rem(-a, b) + b
MOD works for scalars, series, and tables.