Research V4 release
[unix-history] / man / man3 / rand.3
CommitLineData
8ac21c23
KT
1.th RAND III 1/15/73
2.sh NAME
3rand \*- random number generator
4.sh SYNOPSIS
5(seed in r0)
6.br
7.ft B
8jsr pc,srand /to initialize
9.s3
10jsr pc,rand /to get a random number
11.s3
12.nf
13srand(seed)
14int seed;
15.s3
16rand( )
17.fi
18.ft R
19.s3
20.sh DESCRIPTION
21.it Rand
22uses a multiplicative congruential
23random number generator to return successive pseudo-random
24numbers (in r0) in the range from 1 to 2\u\s715\s10\d\*-1.
25.s3
26The generator is reinitialized by calling
27.it srand
28with 1 as argument (in r0).
29It can be set to a random starting point by calling
30.it srand
31with whatever you like as argument,
32for example the low-order word
33of the time.
34.sh WARNING
35The author of this routine has been writing
36random-number generators for many years and has never been
37known to write one that worked.
38.sh BUGS
39The low-order bits are not very random.