The OpenD Programming Language

uniform

Generates a uniformly-distributed number in the range [T.min, T.max] for any integral or character type T. If no random number generator is passed, uses the default rndGen.

If an enum is used as type, the random variate is drawn with equal probability from any of the possible values of the enum E.

Return Value

Type: auto

Random variate drawn from the uniform distribution across all possible values of the integral, character or enum type T.

Examples

auto rnd = MinstdRand0(42);

assert(rnd.uniform!ubyte == 102);
assert(rnd.uniform!ulong == 4838462006927449017);

enum Fruit { apple, mango, pear }
version (D_LP64) // https://issues.dlang.org/show_bug.cgi?id=15147
assert(rnd.uniform!Fruit == Fruit.mango);

Meta