mod

Date:

10-12-2011

NAME

MOD, AMOD, DMOD, IMOD, JMOD, KMOD - Compute remainder

SYNOPSIS

MOD ([A=]a,[P=]p)
AMOD ([A=]a,[P=]p)
DMOD ([A=]a,[P=]p)
IMOD ([A=]a,[P=]p)
JMOD ([A=]a,[P=]p)
KMOD ([A=]a,[P=]p)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

DESCRIPTION

These intrinsic functions compute the remainder of a/p. MOD is the generic function name; the others are specifics. These are elemental intrinsic functions. They accept the following arguments:

a

Must be of type integer or real.

p

Must be of the same type and kind type as a. The result is undefined if p is zero.

These functions evaluate y=a-p* INT(a/p).

NOTES

The MOD, AMOD, and DMOD intrinsic function names can be passed as arguments; the others cannot.

RETURN VALUES

MOD returns the INTEGER remainder of its INTEGER arguments.

AMOD returns the single-precision REAL remainder of its single-precision REAL arguments.

DMOD returns the double-precision REAL remainder of its double-precision REAL arguments.

IMOD returns the INTEGER(KIND=2) remainder of its INTEGER(KIND=2) arguments.

JMOD returns the INTEGER(KIND=4) remainder of its INTEGER(KIND=4) arguments.

KMOD returns the INTEGER(KIND=8) remainder of its INTEGER(KIND=8) arguments.

EXAMPLES

The following examples show the results of calling MOD with all possible combinations of positive and negative integers:

  • MOD(7,4) yields 3.

  • MOD(-7,4) yields -3.

  • MOD(7,-4) yields 3.

  • MOD(-7,-4) yields -3.