next up previous contents index
Next: Arithmetic Assignment Statements Up: Arithmetic Intrinsic Functions Previous: Minimum and Maximum

Other Functions

tabular712

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 tex2html_wrap_inline3191 (rather than tex2html_wrap_inline3193 to tex2html_wrap_inline3195 ) then, assuming the value of TWOPI is suitably defined, the required expression is:
MOD(ATAN2(X,Y) + TWOPI, TWOPI)



Mario Storti
Wed Nov 4 19:32:56 ART 1998