Mail Archives: djgpp/1997/01/30/02:36:05
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.
- Raw text -