MOD
Use MOD when you need the modulus of an integer and a number.
The MOD function returns the modulus that remains after a number is divided by an integer.
- Syntax:
- MOD (single-number-expression, single-integer-expression)
- Meaning:
- MOD (dividend , divisor)
- Returns:
- A single integer
The result is the remainder (modulus) after dividend is divided by divisor. The result has the same sign as divisor.
The dividend is first divided by the integer divisor, resulting in a quotient. The modulus is calculated by multiplying the integer portion of the quotient by divisor and then subtracting that product from dividend.
If divisor is 0, MOD returns "none".
Examples
- MOD (3, 2) or MOD (-3, 2)
Returns 1
- MOD (3, -2) or MOD (-3, -2)
Returns -1
- MOD (-3, 2) or MOD (-3, -2)
Returns 1
- MOD (-3, -2) or MOD (-3, -2)
Returns -1