Elemental Intrinsic Function (Generic): Returns the remainder when the first argument is divided by the second argument.
Syntax
Results:
The result type is the same as a. If p is not equal to zero, the value of the result is a - INT(a / p) * p. If p is equal to zero, the result is undefined.
Specific Name | Argument Type | Result Type |
---|---|---|
INTEGER(1) | INTEGER(1) | |
IMOD | INTEGER(2) | INTEGER(2) |
MOD 1 | INTEGER(4) | INTEGER(4) |
KMOD | INTEGER(8) | INTEGER(8) |
AMOD 2 | REAL(4) | REAL(4) |
QMOD 3 | REAL(16) | REAL(16) |
1 Or JMOD.
2 The setting of compiler option /real_size can affect AMOD. 3 VMS and U*X |
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: MODULO
Examples
MOD (7, 3) has the value 1.
MOD (9, -6) has the value 3.
MOD (-9, 6) has the value -3.
The following shows more examples:
INTEGER I
REAL R
R = MOD(9.0, 2.0) ! returns 1.0
I = MOD(18, 5) ! returns 3
I = MOD(-18, 5) ! returns -3