[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev Lynx 2.8.4 with OpenSSL

From: Duncan Simpson
Subject: Re: lynx-dev Lynx 2.8.4 with OpenSSL
Date: Sat, 03 Feb 2001 20:02:21 +0000

On my linux libc rand manpage says:

<lots snipped>
       The  versions of rand() and srand() in the Linux C Library
       use the same random number generator as random() and sran­
       dom(),  so the lower-order bits should be as random as the
       higher-order bits.  However, on older  rand()  implementa­
       tions,  the lower-order bits are much less random than the
       higher-order bits.

       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,  1990 (1st ed, p. 207)), the following comments are
              "If you want to generate a random integer between 1
              and 10, you should always do it by

                     j=1+(int) (10.0*rand()/(RAND_MAX+1.0));

              and never by anything resembling

                     j=1+((int) (1000000.0*rand()) % 10);

              (which uses lower-order bits)."

       Random-number  generation is a complex topic.  The Numeri­
       cal Recipes in C book (see reference  above)  provides  an
       excellent discussion of practical random-number generation
       issues in Chapter 7 (Random Numbers).
<all tbe rest snipped>

So, IMHO you should prefer random() over rand().
Duncan (-:
"software industry, the: unique industry where selling substandard goods is
legal and you can charge extra for fixing the problems."

; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]