Next: NEAREST, Previous: MOD, Up: Intrinsic Procedures
MODULO — Modulo functionMODULO(A,P) computes the A modulo P.
X = MODULO(A,P)
| A | shall be a scalar of type INTEGER or REAL
|
| P | shall be a scalar of the same type and kind as A
|
INTEGER:MODULO(A,P) has the value R such that A=Q*P+R, where
Q is an integer and R is between 0 (inclusive) and P
(exclusive).
REAL:MODULO(A,P) has the value of A - FLOOR (A / P) * P.
program test_mod
print *, modulo(17,3)
print *, modulo(17.5,5.5)
print *, modulo(-17,3)
print *, modulo(-17.5,5.5)
print *, modulo(17,-3)
print *, modulo(17.5,-5.5)
end program test_mod
| Name | Arguments | Return type | Option
|
AMOD(A,P) | REAL(4) | REAL(4) | f95, gnu
|
DMOD(A,P) | REAL(8) | REAL(8) | f95, gnu
|