Lahey/Fujitsu Fortran

MOD Function

Description

The MOD function returns the remainder from the division of the first argument by the second argument.

Syntax

MOD (a, p)

Arguments

a is an INTENT(IN) scalar or array of type INTEGER or REAL.

p is INTENT(IN) and of the same type and kind as a. Its value must not be zero.

Result

The result is the same type and kind as a. Its value is a-INT(a/p)*p.

Example

write(*,*) mod(23.4,4.0) ! writes 3.4 write(*,*) mod(-23,4) ! writes -3 write(*,*) mod(23,-4) ! writes 3 write(*,*) mod(-23,-4) ! writes -3