Re: [AD] Pending patches request |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
AE wrote:
> >- rand() replaced by (rand()+(rand()>>16)) on test.c
> > This should cause no harm to anyone.
>
> Wouldn't adding two random numbers where the randomness is evenly
> distributed accross the range of possible values create a result where
> there's a greater probability that the number falls in the middle of the
> range than it does of falling somewhere near the edge?
Yes, but that's not exactly what he's doing. Because of the 16 bit
shift, you're probably (quick guess) creating 2^16 uneven (gaussian?)
distributions. Or something like that. I'm almost sure it's not
mathematically correct, though.
It's probably no big deal at all for test.c, but if you want to fix
randomness it probably shouldn't be done like this. From what I
understood of previous mail, the proper way to do random would be
if (microsoft)
rand() & 0x0000FFFF
else
rand() && 0xFFFF0000 >> 16
fi
or something like that. I can see how that would get ugly if you want
to provide for 64 bit systems as well, so I'm not sure how to
"beautify" this. Perhaps we just accept that test isn't truly random?
Allegro users should probably be using the alrand library by Vincent,
for their own programs. If enough people start using that I'm sure it
will be made to work properly for all platforms, if it isn't already.
Hein
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<
Unix is user friendly. It's just very particular about who
it's friends are.
Hein Zelle hein@xxxxxxxxxx
http://www.icce.rug.nl/~hein
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<