Modula-2 || Compiler & Tools || Library || Search Engine
PROCEDURE IntVal() : INTEGER; PROCEDURE RealVal() : REAL; PROCEDURE Random(low, high: INTEGER) : INTEGER; PROCEDURE Flip() : BOOLEAN; PROCEDURE Init(seed: INTEGER);
IntVal, RealVal, Random and Flip return uniformely distributed values for the requested type and value range:
IntVal | 32-bit integer |
RealVal | floating point number out of [0..1) |
Random | integer out of [low..high] |
Flip | TRUE or FALSE |
By default, RandomGenerator takes a seed value that is derived from the current time and the process id. Init allows to override this default. This may be useful to replay sequences of pseudo random numbers or to use better sources for seed values.
Modula-2 || Compiler & Tools || Library || Search Engine