COBOL Manual for TNS/E Programs (H06.03+)
Intrinsic Functions
HP COBOL Manual for TNS/E Programs—520347-003
14-49
RANDOM Function
RANDOM Function
RANDOM, a numeric function, returns a pseudorandom number from a rectangular
distribution.
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 14-33. 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
( )
RANDOMFUNCTION
argument
VST456.vsd










