Mail Archives: djgpp/1999/07/29/18:05:33
Eli Zaretskii wrote:
> On Thu, 29 Jul 1999, Simon De Deyne wrote:
>
> > Thanks for the answer! I did consider this way, but then,
> > i also noticed that the seeding with the time function (srand) isn't
> > as random as when i used the other random function.
>
> Seed has nothing to do with randomness.
>
> > > So to produce a random number between 0 and 99
> > > x = rand() % 100;
>
> The low bits of the random numbers are known to be not very random. If
> you want more random results, try this (untested!):
>
> x = ((double) rand ()) * 100 / RAND_MAX;
Not exactly the correct method (IIRC), but close:
x = ((double) rand ()/RAND_MAX) * 100;
- Raw text -