DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
(BSD System Compatibility)

rand(3bsd)


rand, srand -- (BSD) simple random number generator

Synopsis

   /usr/ucb/cc [flag . . . ] file . . .
   

srand(int seed);

rand(void);

Description

rand uses a multiplicative congruential random number generator with period 2[32] to return successive pseudo-random numbers in the range from 0 to 2[31]-1.

srand can be called at any time to reset the random-number generator to a random starting point. The generator is initially seeded with a value of 1.

References

drand48(3C), rand(3C), random(3bsd)

Notices

The spectral properties of rand leave a great deal to be desired. drand48(3C) rand(3C), and random(3bsd) provide much better, though more elaborate, random-number generators.

The low bits of the numbers generated are not very random; use the middle bits. In particular the lowest bit alternates between 0 and 1.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004