Next: MOVE_ALLOC, Previous: MOD, Up: Intrinsic Procedures

`MODULO`

— Modulo function*Description*:`MODULO(A,P)`

computes the`A`modulo`P`.*Standard*:- Fortran 95 and later
*Class*:- Elemental function
*Syntax*:`RESULT = MODULO(A, P)`

*Arguments*:-
`A`Shall be a scalar of type `INTEGER`

or`REAL`

`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`R`such that`A=Q*P+R`

, where`Q`is an integer and`R`is between 0 (inclusive) and`P`(exclusive).- If
`A`and`P`are of type`REAL`

: `MODULO(A,P)`

has the value of`A - FLOOR (A / P) * P`

.

`P`is zero the result is processor-dependent. - If
*Example*:-
program test_modulo print *, modulo(17,3) print *, 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) end program