Next: Arithmetic Assignment Statements Up: Arithmetic Intrinsic Functions Previous: Minimum and Maximum

Other Functions

 * = AINT(RD) Truncates the fractional part (i.e. as INT) but preserves the data type. * = ANINT(RD) Rounds to the nearest whole number. I = NINT(RD) Converts to integer by rounding to the nearest whole number. * = ABS(IRD) Returns the absolute value of a number (i.e. it changes the sign if negative). R = ABS(X) Computes the modulus of a complex number (i.e. the square-root of the sum of the squares of the two components). * = MOD(IRD,IRD) returns A1 modulo A2, i.e. the remainder after dividing A1 by A2. * = SIGN(IRD,IRD) performs sign transfer: if A2 is negative the result is -A1, if A2 is zero or positive the result is A1. * = DIM(IRD,IRD) returns the positive difference of A1 and A2, i.e. if A1 > A2 it returns (A1-A2), otherwise zero. D = DPROD(R,R) Computes the double precision product of two real values. R = AIMAG(X) Extracts the imaginary component of a complex number. Note that the real component can be obtained by using the REAL function. X = CONJG(X) Computes the complex conjugate of a complex number.

The NINT and ANINT functions round upwards if the fractional part of the argument is 0.5 or more, whereas INT and AINT always round towards zero. Thus:
 INT(+3.5) = 3 NINT(+3.5) = 4
 INT(-3.5) = -3 NINT(-3.5) = -4
The fractional part of a floating point number, X, can easily be found either by:
 X - AINT(X)
or
 MOD(X, 1.0)
In either case, if X is negative the result will also be negative. The ABS function can always be used to alter the sign if required.

The MOD function has other uses. For example it can find the day of the week from an absolute day count such as Modified Julian Date (MJD):
 MOD(MJD,7)
has a value between 0 and 6 for days from Wednesday to Tuesday. Similarly if you use the ATAN2 function but want the result to lie in the range 0 to (rather than to ) then, assuming the value of TWOPI is suitably defined, the required expression is:
 MOD(ATAN2(X,Y) + TWOPI, TWOPI)

Next: Arithmetic Assignment Statements Up: Arithmetic Intrinsic Functions Previous: Minimum and Maximum
Helen Rowlands
8/27/1998