1rand(3UCB) SunOS/BSD Compatibility Library Functions rand(3UCB)
2
3
4
6 rand, srand - simple random number generator
7
9 /usr/ucb/cc [ flag ... ] file ...
10
11 int rand();
12
13
14 int srand(seed)
15 unsigned seed;
16
17
19 rand() uses a multiplicative congruential random number generator with
20 period 2^32 to return successive pseudo-random numbers in the range
21 from 0 to 2^31 −1.
22
23
24 srand() can be called at any time to reset the random-number generator
25 to a random starting point. The generator is initially seeded with a
26 value of 1.
27
29 drand48(3C), rand(3C), random(3C)
30
32 Use of these interfaces should be restricted to only applications writ‐
33 ten on BSD platforms. Use of these interfaces with any of the system
34 libraries or in multi-thread applications is unsupported.
35
36
37 The spectral properties of rand() leave a great deal to be desired.
38 drand48(3C) and random(3C) provide much better, though more elaborate,
39 random-number generators.
40
41
42 The low bits of the numbers generated are not very random; use the mid‐
43 dle bits. In particular the lowest bit alternates between 0 and 1.
44
45
46
47SunOS 5.11 30 Oct 2007 rand(3UCB)