Clicky
Showing changes from revision #1 to #2:
(追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)
modulo(a,p)
computes the a
modulo p
.
(削除) Fortran 95 and later (削除ここまで)(追記) Fortran 95 (追記ここまで)(追記) and later (追記ここまで)
(削除) Elemental function (削除ここまで)(追記) Elemental function (追記ここまで)
result = modulo(a, p)
a
- Shall be a scalar of type integer
or real
p
- Shall be a scalar of the same type and kind as a
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
.
In all cases, if p
is zero the result is processor-dependent.
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