Module Random Reference

A simple and fast pseudo-random number generator

Constants

modulo = 2147483647;

Randomization modulo. Equal to 2^31 - 1.

Types

This section is empty.

Variables

seed: INTEGER;

Procedures

PROCEDURE Int (range: INTEGER): INTEGER;

Returns a random integer number from 0 to (range - 1).

For example, Int(6) may return a number from 0 to 5.

range must be in range [1; 2^31 - 2].

PROCEDURE PutSeed (newSeed: INTEGER);

Sets the value of the random seed. Any values are allowed, although values that are not in [1..2^31 - 2] range will be mapped into this range.

The same random seed results in the same sequence of random numbers.

PROCEDURE Randomize;

Initializes the randomization process using current time. This procedure is called automatically on module initialization.

PROCEDURE Uniform (): REAL;

Returns a random real number x, where 0 <= x < 1.