8.62. File tom/Random

class tom.Random

inherits

Behaviour supers: All

instance tom.Random

inherits

Behaviour supers: All

methods


deferred double
  next;

Return a double random number.


deferred int
  next;

Return an integer random number.


int (result)
  next int limit
pre
  limit > 1
post
  result >= 0 && result < limit;

Return a number in the range [0, limit).

class tom.IntegerRandom

Superclass for use by random number generators which customarily return ints.

inherits

State supers: Random, Limits

instance tom.IntegerRandom

methods


double
  next;

Return the next double value, in the range [0, 1.0).

class tom.DoubleRandom

Superclass for use by random number generators which customarily return ints.

inherits

State supers: Random, Limits

instance tom.DoubleRandom

methods


int (result)
  next;

Return the next integer value, in the range [0, INT_MAX].

class tom.MinimalRandom

MinimalRandom implements IntegerRandom. It uses seeds to generate a repeatable sequence of pseudo-random integers.

inherits

State supers: State, IntegerRandom

variables

const ia = 16807;

Constants needed by the algorithm.

const im = 2147483647;

const iq = 12773;

const ir = 2836;

instance tom.MinimalRandom

variables

int seed;

The seed from which we feed.

methods


id (self)
  init int initial_seed
pre
  initial_seed > 0;

Designated initializer.


id
  init;

Initialize this instance with a seed derived from the current moment in time and the hashq value of self.


int
  next;

Return the next random positive int value.