20 lines
520 B
Groff
20 lines
520 B
Groff
|
|
SUBROUTINES
|
|
rand - standard random number generator
|
|
INVOCATION
|
|
srand( seed )
|
|
unsigned seed;
|
|
int rand()
|
|
EXPLANATION
|
|
Rand(3) uses a full period, mixed linear congruential
|
|
generator to return a pseudo-random number in the
|
|
range 0 to 32767 {INT_MAX}. The formula used is:
|
|
seed = (1103515245 * seed + 12345) % 2147483648
|
|
Srand(3) sets the seed to an initial value, the default
|
|
is 1.
|
|
RESULTS
|
|
Rand(3) returns 15 bits from the high order word of seed.
|
|
REFERENCES
|
|
lrand(3)
|
|
|