Description: | Returns the remainder when the first argument is divided by the second argument. | ||
Class: | Elemental function; Generic | ||
Arguments: | A | Must be of type integer or real. | |
P | Must have the same type and kind parameters as A. | ||
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) |
DMOD | REAL(8) | REAL(8) |
QMOD | REAL(16) | REAL(16) |
^{1} Or JMOD.
^{2} The setting of compiler options specifying real size can affect AMOD. |
Examples
MOD (7, 3) has the value 1.
MOD (9, -6) has the value 3.
MOD (-9, 6) has the value -3.