062. MODULO vs. MOD function#

topic: Math intrinsic functions

Note

This tip is a draft1.

Fortran has similar MODULO and MOD functions. MODULO (MOD) takes the sign of the 2nd (1st) argument.

print*,modulo([-1,0,1],2) ! 1 0 1 print*,mod([-1,0,1],2) ! -1 0 1 print*,modulo([-1,0,1],-2) ! -1 0 -1 print*,mod([-1,0,1],-2) ! -1 0 1 end



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.