Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

RANGE - Difference value

The RANGE function returns a value that is equal to the value of the maximum argument minus the value of the minimum argument.
The type of this function depends upon the argument types as follows:

Argument type

Function type

all arguments integer
all arguments numeric
mix of integer/numeric

integer
numeric
numeric

Format


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


Argument

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

Returned values

  1. The returned value is equal to the greatest value of argument-1 minus the least value of argument-1. The comparisons used to determine the greatest and least values are made according to the rules for simple conditions.

  2. The error default value is -1.


See also:
        MIN, MAX, MEAN, MEDIAN, MIDRANGE, ORD-MAX, ORD-MIN, SUM

Example 9-38

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  RES PIC 9(3).
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    COMPUTE RES = FUNCTION RANGE (12 32 5 8 17 9).
    DISPLAY RES UPON T.
    STOP RUN.

Result:              027