Add copyright
[unix-history] / usr / src / lib / libc / stdlib / rand.3
CommitLineData
42984a78 1.\" @(#)rand.3 6.1 (Berkeley) %G%
fc9e796e 2.\"
42984a78 3.TH RAND 3C ""
fc9e796e
KM
4.AT 3
5.SH NAME
6rand, srand \- random number generator
7.SH SYNOPSIS
8.nf
9.B srand(seed)
10.B int seed;
11.PP
12.B rand()
13.fi
14.SH DESCRIPTION
c9573fe5
KM
15.ft B
16The newer random(3) should be used in new applications;
17rand remains for compatibilty.
18.ft R
19.PP
fc9e796e
KM
20.I Rand
21uses a multiplicative congruential
22random number generator
23with period 2\u\s732\s0\d
24to return successive pseudo-random
25numbers in the range from 0 to 2\u\s731\s10\d\-1.
26.PP
27The generator is reinitialized by calling
28.I srand
29with 1 as argument.
30It can be set to a random starting point by calling
31.I srand
32with whatever you like as argument.
c9573fe5
KM
33.SH "SEE ALSO"
34random(3)