Commit | Line | Data |
---|---|---|
42984a78 | 1 | .\" @(#)rand.3 6.1 (Berkeley) %G% |
fc9e796e | 2 | .\" |
42984a78 | 3 | .TH RAND 3C "" |
fc9e796e KM |
4 | .AT 3 |
5 | .SH NAME | |
6 | rand, 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 |
16 | The newer random(3) should be used in new applications; | |
17 | rand remains for compatibilty. | |
18 | .ft R | |
19 | .PP | |
fc9e796e KM |
20 | .I Rand |
21 | uses a multiplicative congruential | |
22 | random number generator | |
23 | with period 2\u\s732\s0\d | |
24 | to return successive pseudo-random | |
25 | numbers in the range from 0 to 2\u\s731\s10\d\-1. | |
26 | .PP | |
27 | The generator is reinitialized by calling | |
28 | .I srand | |
29 | with 1 as argument. | |
30 | It can be set to a random starting point by calling | |
31 | .I srand | |
32 | with whatever you like as argument. | |
c9573fe5 KM |
33 | .SH "SEE ALSO" |
34 | random(3) |