Commit | Line | Data |
---|---|---|
2bae4d9a | 1 | .\" @(#)rand.3 6.2 (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 | |
2bae4d9a KM |
22 | random number generator with period |
23 | .if t 2\u\s732\s0\d | |
24 | .if n 2**32 | |
fc9e796e | 25 | to return successive pseudo-random |
2bae4d9a KM |
26 | numbers in the range from 0 to |
27 | .if t 2\u\s731\s10\d\(mi1. | |
28 | .if n (2**31)\(mi1 | |
fc9e796e KM |
29 | .PP |
30 | The generator is reinitialized by calling | |
31 | .I srand | |
32 | with 1 as argument. | |
33 | It can be set to a random starting point by calling | |
34 | .I srand | |
35 | with whatever you like as argument. | |
c9573fe5 KM |
36 | .SH "SEE ALSO" |
37 | random(3) |