Elemental Intrinsic Function (Generic): Returns the modulo of the arguments.
Syntax
result = MODULO (a, p)
a
(Input) Must be of type integer or real.
p
(Input) Must have the same type and kind parameters as a.
Results
The result type is the same a. The result value depends on the type of a, as follows:
If p is equal to zero (regardless of the type of a), the result is undefined.
See Also
Examples
MODULO (7, 3) has the value 1.
MODULO (9, -6) has the value -3.
MODULO (-9, 6) has the value 3.
The following shows more examples:
INTEGER I
REAL R
I= MODULO(8, 5) ! returns 3 Note: q=1
I= MODULO(-8, 5) ! returns 2 Note: q=-2
I= MODULO(8, -5) ! returns -2 Note: q=-2
R= MODULO(7.285, 2.35) ! returns 0.2350001 Note: q=3
R= MODULO(7.285, -2.35) ! returns -2.115 Note: q=-4