Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2000:
[Freeciv-Dev] Re: Random generator not random at all
Home

[Freeciv-Dev] Re: Random generator not random at all

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Random generator not random at all
From: Jarda Benkovsky <pvt.benkovsk@xxxxxxxxx>
Date: Wed, 19 Jul 2000 10:02:55 +0200

Falk Hueffner wrote:
> ARGH it uses % to reduce the space. This is about the first thing one
> lears about RNGs... To cite rand(3) on Linux:
>               "If you want to generate a random integer between 1
>               and 10, you should always do it by using high-order


Hmm, but it's not a problem of lower bits only. My rand(3) man page says
also:

       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.

Indeed, if I do   rand() % 2   I get saner results than those above!

                                        Edheldil



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