gm2-libs-iso/RandomNumber (The GNU Modula-2 Compiler)

#### 4.4.39 gm2-libs-iso/RandomNumber ¶

    DEFINITION MODULE RandomNumber ;

    (*
        Description: provides primitives for obtaining random numbers on
                     pervasive data types.
    *)

    FROM SYSTEM IMPORT BYTE ;
    EXPORT QUALIFIED Randomize, RandomInit, RandomBytes,
                     RandomCard, RandomShortCard, RandomLongCard,
                     RandomInt, RandomShortInt, RandomLongInt,
                     RandomReal, RandomLongReal, RandomShortReal ;

    (*
       Randomize - initialize the random number generator with a seed
                   based on the microseconds.
    *)

    PROCEDURE Randomize ;

    (*
       RandomInit - initialize the random number generator with value, seed.
    *)

    PROCEDURE RandomInit (seed: CARDINAL) ;

    (*
       RandomBytes - fills in an array with random values.
    *)

    PROCEDURE RandomBytes (VAR a: ARRAY OF BYTE) ;

    (*
       RandomInt - return an INTEGER in the range [low .. high].
    *)

    PROCEDURE RandomInt (low, high: INTEGER) : INTEGER ;

    (*
       RandomShortInt - return an SHORTINT in the range [low..high].
    *)

    PROCEDURE RandomShortInt (low, high: SHORTINT) : SHORTINT ;

    (*
       RandomLongInt - return an LONGINT in the range [low..high].
    *)

    PROCEDURE RandomLongInt (low, high: LONGINT) : LONGINT ;

    (*
       RandomShortCard - return a SHORTCARD in the range [low..high].
    *)

    PROCEDURE RandomShortCard (low, high: CARDINAL) : CARDINAL ;

    (*
       RandomCard - return a CARDINAL in the range [low..high].
    *)

    PROCEDURE RandomCard (low, high: CARDINAL) : CARDINAL ;

    (*
       RandomLongCard - return an LONGCARD in the range [low..high].
    *)

    PROCEDURE RandomLongCard (low, high: LONGCARD) : LONGCARD ;

    (*
       RandomReal - return a REAL number in the range 0.0..1.0
    *)

    PROCEDURE RandomReal () : REAL ;

    (*
       RandomShortReal - return a SHORTREAL number in the range 0.0..1.0
    *)

    PROCEDURE RandomShortReal () : SHORTREAL ;

    (*
       RandomLongReal - return a LONGREAL number in the range 0.0..1.0
    *)

    PROCEDURE RandomLongReal () : LONGREAL ;

    END RandomNumber.