ILE COBOL Language Reference


The RANDOM function returns a numeric value that is a pseudo-random number from a rectangular distribution.

The function type is numeric.

>>-FUNCTION RANDOM--+------------------+-----------------------><
If argument-1 is specified, it must be zero or a positive integer, up to and including (10**18)-1 which is the maximum value that can be specified in a PIC9(18) fixed item; however, only those in the range from zero up to and including 2,147,483,645 will yield a distinct sequence of pseudorandom numbers.

If a subsequent reference specifies argument-1, a new sequence of pseudo-random numbers is started.

If the first reference to this function in the run unit does not specify argument-1, the seed value used will be zero.

In each case, subsequent references without specifying argument-1 return the next number in the current sequence.

The returned value is exclusively between zero and one.

For a given seed value, the sequence of pseudorandom numbers will always be the same.

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]