XFA Specification
Chapter 23, FormCalc Specification
Arithmetic Built-in Functions
839
Mod()
This function returns the modulus of one number divided by another.
Syntax
Mod(n1, n2)
Parameters
n1
is the dividend number.
n2
is the divisor number.
Returns
The modulus or null if any of its parameter are null.
The modulus is the remainder of the implied division of the dividend and the divisor. The sign of the
remainder always equals the sign of the dividend.
For integral operands, this is simple enough. For floating point operands, the floating point remainder
r
of
Mod(n1, n2)
is defined as
r = n1 - (n2 * q)
where
q
is an integer whose sign is negative when
n1 / n2
is negative, and positive when
n1 / n2
is positive, and whose magnitude is the largest integer
less than the quotient
n1 / n2
.
If the divisor is zero, the function generates an error exception.
Examples
Calling Mod() as follows …
Mod(64, 2)
Mod(-13, 3)
Mod(13, -3)
Mod(-13.6, 2.2)
Returns
0.
-1
1
-0.4