modulo
- Date:
10-12-2011
NAME
MODULO - Modulo function
SYNOPSIS
MODULO ([A=]a, [P=]p)
IMPLEMENTATION
Cray Linux Environment (CLE)
STANDARDS
Fortran
DESCRIPTION
The MODULO function returns the remainder of a divided by p using modulo math. The result always has the sign of the modulo base p.
This function accepts the following arguments:
- a
Must be of type integer or real
- p
Must be of the same type and kind type parameter as a
MODULO is an elemental function. The name of this intrinsic cannot be passed as an argument.
RETURN VALUES
The result type and type parameter are the same as a.
When a is of type integer, if p is not equal to zero, MODULO (a,p) has the value r such that a=q*p+r, where q is an integer. The inequality 0 <= r < p holds if p > 0, and p < r <= 0 holds if p < 0. If p = 0, the result is 0.
When a is of type real, if p is not equal to zero, the value of the result is a- FLOOR (a/p) *p. The result can be a NaN when that value is available.
EXAMPLES
Example 1. MODULO(8,5) yields 3.
Example 2. MODULO(-8,5) yields 2.
Example 3. MODULO(8,-5) yields -2.
Example 4. MODULO(-8,-5) yields -3.