| Syntax |
mod (num, base)
|
| Params |
num is a number. It acts as the dividend in this operation.
base is a number. It acts as the divisor in this operation.
|
| Action |
Divides num by base and calculates the remainder. (In mathematical terms, this function calculates num modulo base.)
|
| Returns |
The remainder that results when num is divided by base. (In mathematical terms, this function returns num modulo base.)
|
| Examples |
mod (43, 10)
» 3 // 43/10 = 4 with a remainder of 3
value = 16;
mod (value, 2) == 0
» true
Typical use of mod operator to determine if a value is even.
mod (3, 4)
» 3 // 3/4=0 with a remainder of 3
398 % 3
» 2
Note that here we use the % operator.
|
| Notes |
You can also use the % operator to carry out modulus calculations. This is an infix operator which is placed between the num and base.
|