mod(a,p) computes the remainder of the division of a by p. It is calculated as a - (int(a/p) * p).
FORTRAN 77 and later
result = mod(a, p)
a - Shall be a scalar of type integer or realp - Shall be a scalar of the same type as a and not equal to zeroThe kind of the return value is the result of cross-promoting the kinds of the arguments.
program test_mod
print *, mod(17,3)
print *, mod(17.5,5.5)
print *, mod(17.5d0,5.5)
print *, mod(17.5,5.5d0)
print *, mod(-17,3)
print *, mod(-17.5,5.5)
print *, mod(-17.5d0,5.5)
print *, mod(-17.5,5.5d0)
print *, mod(17,-3)
print *, mod(17.5,-5.5)
print *, mod(17.5d0,-5.5)
print *, mod(17.5,-5.5d0)
end program test_mod