HP 3000 Manuals

MIDRANGE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

MIDRANGE Function 

The MIDRANGE (middle range) function returns a numeric value that is the
arithmetic mean (average) of the value of the minimum parameter and the
maximum parameter.  The function type is numeric.

Syntax 

     FUNCTION MIDRANGE ({parameter-1}...)

Parameters 

parameter-1           Must be class numeric.

Return Value 

The returned value is the arithmetic mean of the greatest parameter-1 
value and the least parameter-1 value.  The comparisons used to determine
the greatest and least values are made according to the rules for simple
conditions.  See the section "Simple Conditions" in Chapter 8  for
additional information.

Example 

     01  TAB.
         05  ELEMENT   PIC S999V99
                         OCCURS 4 TIMES VALUE ZERO.
     01  NUM-MIDRANGE  PIC S999V99 VALUE ZERO.
          :
     MOVE 1.25 TO ELEMENT (1)
     MOVE 3.50 TO ELEMENT (2)
     MOVE 8.75 TO ELEMENT (3)
     MOVE 0.25 TO ELEMENT (4)

     COMPUTE NUM-MIDRANGE = FUNCTION MIDRANGE (1 7 9 23 85).
     DISPLAY NUM-MIDRANGE
     COMPUTE NUM-MIDRANGE = FUNCTION MIDRANGE ( ELEMENT (ALL) )
     DISPLAY NUM-MIDRANGE

The above example displays the following:

     +043.00
     +004.50



MPE/iX 5.0 Documentation