[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Why am I not getting the results I expect...

> >
> > So if you have random () returning long on your machine, this should
> > suffice
> >
> >     ((int) (random ()) % 24) + 1
> Thanks Venkatest.  I figured this out by accident yesterday.  Now I know
> the reason why it worked.
> Thaths

A small piece of information:

The lower order bits of a random number generated by the "remainder" method
are supposed to be less random than the higher order bits. Saw this in a
book "Numerical Recipies in C".

So, according to the book, the above method is not, academically, the best.
But what the heck, it works fine if you are not running some critical
scientific simulations.