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

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


rand in MSVC6 only fills the lower 16 bits.  Maybe lower 15.  I believe 
that RAND_MAX is 32767 on that, so that would be the lower 15.  I don't 
know about MSVC.NET, because the random number generators are very 
inconsistent in their "goodness" and you never use just raw rand() anyways -
- you apply some of formulas to them, I have bring my own RNG to use ;), 
with its own interface.

Gillius

On 25 May 2003 at 21:17, Sven Sandberg wrote:

> 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
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: ObjectStore.
> If flattening out C++ or Java code to make your application fit in a
> relational database is painful, don't do it! Check out ObjectStore.
> Now part of Progress Software. http://www.objectstore.net/sourceforge
> -- 
> https://lists.sourceforge.net/lists/listinfo/alleg-developers






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