COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 212 RANGE Function
Code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUMERIC-ARRAY.
05 PICTURE 9V99 VALUE 0.05.
05 PICTURE 9V99 VALUE 1.15.
05 PICTURE 9V99 VALUE 2.50.
05 PICTURE 9V99 VALUE 3.75.
05 PICTURE 9V99 VALUE 4.55.
01 NUM-ARRAY REDEFINES NUMERIC-ARRAY.
05 NUM OCCURS 5 TIMES PICTURE 9V99.
PROCEDURE DIVISION.
DISPLAY FUNCTION RANGE (NUM(ALL))
DISPLAY FUNCTION RANGE (9 2 5 3.5)
DISPLAY FUNCTION RANGE (1.5 3.6 7.8 4.9)
Output:
4.50
7.0
6.3
REM Function
REM, a numeric function, returns the remainder that results from dividing its first argument by its
second argument.
dividend
is a numeric argument.
divisor
is a nonzero numeric argument.
If ARRAY1 has only two elements, the first of which satisfies the requirements for dividend
and the second of which satisfies the requirements of divisor, then
FUNCTION REM (ARRAY1(ALL))
returns the remainder that results from dividing ARRAY1(1) by ARRAY1(2).
The returned value is the remainder of dividend divided by divisor, which is defined:
dividend - (divisor * FUNCTION INTEGER-PART (dividend / divisor))
REM Function 687