インテル® Fortran コンパイラー 19.0 デベロッパー・ガイドおよびリファレンス

MOD

Elemental Intrinsic Function (Generic): Returns the remainder when the first argument is divided by the second argument.

result = MOD (a, p)

a

(Input) Must be of type integer or real.

p

(Input)Must have the same type and kind parameters as a. It must not have a value of zero.

Results

The result type and kind are the same as a. If p is not equal to zero, the value of the result is a - INT( a/ p) * p. If p is equal to zero, the result is undefined.

Specific Name

Argument Type

Result Type

BMOD

INTEGER(1)

INTEGER(1)

IMOD1

INTEGER(2)

INTEGER(2)

MOD 2

INTEGER(4)

INTEGER(4)

KMOD

INTEGER(8)

INTEGER(8)

AMOD 3

REAL(4)

REAL(4)

DMOD 3,4

REAL(8)

REAL(8)

QMOD

REAL(16)

REAL(16)

1 Or HMOD.

2 Or JMOD.

3 The setting of compiler options specifying real size can affect AMOD and DMOD.

4 The setting of compiler options specifying double size can affect DMOD.

Example

MOD (7, 3) has the value 1.

MOD (9, -6) has the value 3.

MOD (-9, 6) has the value -3.

The following shows more examples:

 INTEGER I
 REAL R
 R = MOD(9.0, 2.0)  ! returns 1.0
 I = MOD(18, 5)     ! returns 3
 I = MOD(-18, 5)    ! returns -3
 I = MOD( 8, 5)     ! returns 3
 I = MOD(-8, 5)     ! returns -3
 I = MOD( 8,-5)     ! returns 3
 I = MOD(-8,-5)     ! returns -3

See Also