up | Inhaltsverzeichniss | Kommentar

Manual page for RAND(3V)

rand, srand - simple random number generator

SYNOPSIS

srand(seed)
int seed;

rand()

DESCRIPTION

rand() uses a multiplicative congruential random number generator with period 22 to return successive pseudo-random numbers in the range from 0 to 21-1.

srand() can be called at any time to reset the random-number generator to a random starting point. The generator is initially seeded with a value of 1.

SYSTEM V DESCRIPTION

rand() returns successive pseudo-random numbers in the range from 0 to 25-1.

SEE ALSO

drand48.3 random.3

NOTES

The spectral properties of rand() leave a great deal to be desired. drand48.3 and random.3 provide much better, though more elaborate, random-number generators.

BUGS

The low bits of the numbers generated are not very random; use the middle bits. In particular the lowest bit alternates between 0 and 1.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97