Re: [AD] rand() vs random()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Angelo Mottola wrote:
No, unfortunately that doesn't help here...
Instead, I've tried replacing rand() with (rand()>>16) and this improved
randomness a lot.

Then (rand()+(rand()>>16)) should work for you too? I'd vote for that, as it works both on platforms where the most random bits are in high 16 and in low 16 bits, as well as on platforms with only 15 bit random numbers.

Can we always assume rand() to fill all 32 bits of an int
(or better, is RAND_MAX always the highest 32bit number)?

It's only guaranteed to be at least 32767, and Watcom (and maybe MSVC?) equal this limit.

--
Sven





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/