Script functions reference > Script functions in alphabetical order > M > Mod

Mod
Syntax
Mod(a, n)
a
n
The number a will be divided by (the divisor).
Description
This function executes a modulo (mod) operation, and returns the remainder after division of one number (the dividend) by another (the divisor). Given two numbers a (dividend) and n (divisor), Mod(a,n) returns the remainder of the division of a by n. For example, Mod(5,2) evaluates to 1 because 5 divided by 2 leaves a quotient of 2 and a remainder of 1.
Returns
The remainder after division of one number (the dividend) by another (the divisor). The remainder returned is the least positive remainder (dividend/divider=quotient+remainder).
Note:
When the dividend is a negative number, the remainder will be negative as well. For example, Mod(-5,2) evaluates to -1 because -5 divided by 2 leaves a quotient of -2 and a remainder of -1 (-5/2=-2+(-1)). The sign of the divisor (+ or -) does not affect the result.
Example
Mod(9,3); //returns 0 (9/3=3+0)
Mod(106,10); //returns 6 (106/10=10+6)
Mod(-106,10); //returns -6 (-106/10=-10+(-6))
Mod(106,-10); //returns 6 (106/10=10+6)
Mod(-106,-10); //returns -6 (-106/10=-10+(-6)
Mod(43,5); //returns 3 (43/5=8+3)
Mod(43,-5); //returns 3 (43/5=8+3)
OpenText StreamServe 5.6.2 Updated: 2018-01-26