Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

MIDRANGE - Mean of minimum and maximum arguments

The MIDRANGE function returns a numeric value that is the arithmetic mean (average) of the values of the minimum argument and the maximum argument.
The type of this function is numeric.

Format


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


Argument

  1. argument-1 must be class "numeric".

Returned values

  1. The returned value is the arithmetic mean of the greatest argument value and the least argument value. The comparisons used to determine the greatest and least values are made according to the rules for simple conditions (see section "Conditions").

  2. The error default value is 0.


See also:       
MIN, MAX, RANGE, MEAN, MEDIAN, SUM

Example 9-27

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  R PIC 999V999.
01  RES PIC 999.999.
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    COMPUTE R = FUNCTION MIDRANGE (12 32 5 8 17 9).
    MOVE R TO RES.
    DISPLAY RES UPON T.
    STOP RUN.

Result:              018.500