Date: Thu, 30 Jan 1997 09:28:51 +0200 (IST) From: Eli Zaretskii To: Pascal Massimino cc: djgpp AT delorie DOT com Subject: Re: Random numbers In-Reply-To: <5clv5m$n2m@nef.ens.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On 28 Jan 1997, Pascal Massimino wrote: > * do not use the lowest bits of rand(). Too bad random properties. > Try printf'ing rand()&0x01 for instance, you'll be surprised. > So, better use ( rand()>>4 ) or ( rand()>>7 ), for instance... A much better way is to use `random' instead of `rand'. It is a POSIX function (AFAIK) and is documented to generate numbers whose bits are *all* rundom; the docs even give you an example of using the lower 2 bits to get a random number between 0 and 3.