Next: , Previous: MINEXPONENT, Up: Intrinsic Procedures


8.79 MOD — Remainder function

Description:
MOD(A,P) computes the remainder of the division of A by P. It is calculated as A - (INT(A/P) * P).
Option:
f95, gnu
Class:
elemental function
Syntax:
X = MOD(A,P)
Arguments:

A shall be a scalar of type INTEGER or REAL
P shall be a scalar of the same type as A and not equal to zero

Return value:
The kind of the return value is the result of cross-promoting the kinds of the arguments.
Example:
          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
     

Specific names:

Name Arguments Return type Option
AMOD(A,P) REAL(4) REAL(4) f95, gnu
DMOD(A,P) REAL(8) REAL(8) f95, gnu