Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!riley From: riley@batcomputer.tn.cornell.edu (Daniel S. Riley) Newsgroups: comp.lang.fortran Subject: Re: fortran statement Message-ID: <8531@batcomputer.tn.cornell.edu> Date: 31 Jul 89 13:51:59 GMT References: <28605@beta.lanl.gov> <588BLUMBERG@BGUVM> <10632@smoke.BRL.MIL> Reply-To: riley@tcgould.tn.cornell.edu (Daniel S. Riley) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 30 In article <10632@smoke.BRL.MIL> chidsey@brl.arpa (Irving Chidsey (INF) ) writes: >In article <588BLUMBERG@BGUVM> BLUMBERG@BGUVM.BITNET (Dan Blumberg, Dept. Of Geog. Ben Gurion Univ. Israel) writes: >Sorry, but mod( n, 2 ) is almost certainly Fortran for N modulo 2, which is >mathematics for n/2 with no fractional part. > >I don't thinkit is standard fortran, but it is common fortran. Ok, enough of this. mod() is the remainder function. mod(n, 2) returns the remainder when n is divided by 2--this is the usual way to check for even or odd (or test the least significant bit, same thing). It is a standard FORTRAN-77 intrinsic. The definition is something like mod(n, m) = n - m*int(n/m) mod() is really misnamed, since it returns the remainder, not the modulo. (For those who care--the remainder takes the sign of the first argument, the modulo takes the sign of the second. mod(x, 2*pi) ought to return a number between 0 and 2*pi, but in FORTRAN-77 it returns a number between -2*pi and 2*pi, depending on the sign of x.) As far as I know, you could declare an array named mod(), but this is generally considered to be bad (and confusing) programming practice. -Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley) -Wilson Lab, Cornell U.