p - Shall be a scalar of the same type and kind as a

Return value

The type and kind of the result are those of the arguments.

If a and p are of type integer: modulo(a,p) has the value of a - floor (real(a) / real(p)) * p.

If a and p are of type real: modulo(a,p) has the value of a - floor (a / p) * p.

In all cases, if p is zero the result is processor-dependent.

Example

program test_moduloprint*,modulo(17,3)! yields 2print*,modulo(17.5,5.5)print*,modulo(-17,3)print*,modulo(-17.5,5.5)print*,modulo(17,-3)print*,modulo(17.5,-5.5)endprogram