Original von http://www.freebsd.org/cgi/man.cgi?q....0&format=html
In 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 follow-
ing comments are made:
"If you want to generate a random integer between 1 and 10, you
should always do it by using high-order bits, as in
j = 1 + (int) (10.0 * (rand() / (RAND_MAX + 1.0)));
and never by anything resembling
j = 1 + (rand() % 10);
(which uses lower-order bits)."
Random-number generation is a complex topic. The Numerical Recipes in
C book (see reference above) provides an excellent discussion of prac-
tical random-number generation issues in Chapter 7 (Random Numbers).
For a more theoretical discussion which also covers many practical
issues in depth, see Chapter 3 (Random Numbers) in Donald E. Knuth's
The Art of Computer Programming, volume 2 (Seminumerical Algorithms),
2nd ed.; Reading, Massachusetts: Addison-Wesley Publishing Company,
1981.