.\" with contribution from Francesco Potorti <F.Potorti@cnuce.cnr.it>
.\" Modified 2003-11-15, aeb, added rand_r
.\"
-.TH RAND 3 2007-07-26 "" "Linux Programmer's Manual"
+.TH RAND 3 2008-03-07 "" "Linux Programmer's Manual"
.SH NAME
rand, rand_r, srand \- pseudo-random number generator
.SH SYNOPSIS
the lower-order bits are much less random than the higher-order bits.
Do not use this function in applications intended to be portable
when good randomness is needed.
-.PP
-In
-.I Numerical Recipes in C: The Art of Scientific Computing
-(William H. Press, Brian P. Flannery, Saul A. Teukolsky, William
-T. Vetterling; New York: Cambridge University Press, 1992 (2nd ed.,
-p. 277)), the following comments are made:
-.PP
-.RS 4
-"If you want to generate a random integer between 1 and 10, you should
-always do it by using high-order bits, as in
-.in +4n
-.sp
-j = 1 + (int) (10.0 * (rand() / (RAND_MAX + 1.0)));
-.sp
-.in
-and never by anything resembling
-.in +4n
-.sp
-j = 1 + (rand() % 10);
-.sp
-.in
-(which uses lower-order bits)."
-.RE
-.PP
-Random-number generation is a complex topic.
-The
-.I Numerical Recipes in C
-book (see reference above)
-provides an excellent discussion of practical random-number generation
-issues in Chapter 7 (Random Numbers).
-.PP
-For a more theoretical discussion which also covers many practical issues
-in depth, see Chapter 3 (Random Numbers) in Donald E. Knuth's
-.IR "The Art of Computer Programming" ,
-volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts:
-Addison-Wesley Publishing Company, 1981.
+(Use
+.BR random (3)
+instead.)
.SH EXAMPLE
POSIX.1-2001 gives the following example of an implementation of
.BR rand ()