next up previous contents index
Next: Other Functions Up: Arithmetic Intrinsic Functions Previous: Type Conversion Functions

Minimum and Maximum

The MIN and MAX functions are unique in being able to take any number of arguments from two upwards; the result has the same data type as the arguments.

tabular705

These two functions can, of course, be combined to limit a value to a certain range. For example, to limit a value TEMPER to the range 32 to 212 you can use an expression such as:
MAX(32.0, MIN(TEMPER, 212.0))
Note that the minimum of the range is an argument of the MAX function and vice-versa.

To find the largest (or smallest) element of a large array it is necessary use a loop.

 
*Find largest value in array T of N elements:  
      TOP = T(1) 
      DO 25,I = 2,N 
         TOP = MAX(T(I), TOP) 
25    CONTINUE 
*TOP now contains the largest element of T.



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