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

argument
is zero or a positive integer.
The first time a run unit calls RANDOM, RANDOM generates a series of pseudorandom numbers
and returns the first number in the series. If argument is specified, RANDOM uses the value of
argument as the seed; if not, it uses the default seed, one.
Each subsequent time that the run unit calls RANDOM without specifying argument, RANDOM
returns the next pseudorandom number in the series. If the run unit calls RANDOM again and
specifies argument, RANDOM generates a new series of pseudorandom numbers and returns
the first number in the new series.
The same value of argument always generates the same sequence of pseudorandom numbers.
The returned value is always greater than or equal to 0 and less than 1.
Example 211 RANDOM Function
Code:
DISPLAY FUNCTION RANDOM (0)
DISPLAY FUNCTION RANDOM (15)
DISPLAY FUNCTION RANDOM (253)
DISPLAY FUNCTION RANDOM (4067)
DISPLAY FUNCTION RANDOM (32767)
Output:
0.000000000
0.707956564
0.007660018
0.886242720
0.792491424
RANGE Function
RANGE is a function that returns the difference between its maximum and minimum arguments. Its
type depends on the type of its arguments, as this table shows:
Function TypeArgument Type
IntegerInteger
NumericNumeric (some can be integer)
argument
is an integer or numeric argument. Integer and numeric arguments can be mixed, because
integers are of the class numeric.
argument can be an array; for example,
FUNCTION RANGE (ARRAY1(ALL))
returns the difference between the largest and smallest elements of the array ARRAY1.
The returned value is the value of the greatest argument minus the value of the least argument
(where the greatest and least arguments are determined according to the rules for evaluating simple
conditions). If two arguments have the same greatest value, the leftmost of the two is considered
the greatest. If two arguments have the same least value, the leftmost of the two is considered the
least.
686 Intrinsic Functions