Mail Archives: djgpp/1997/05/30/13:54:18
Hi all,
When using the 'random' command in the form:
printf("%d\n", random() & 10);
The numbers produced are always either 0, 2, 8 or 10. If I use say 2 as my
range, the numbers produced are only 0 or 2. I don't seem to be able to
get a well varied set of random numbers (i.e. all the numbers in the range
eventually appear). Using the command form:
prinf("%d\n", random(10));
produces the same sequence of very large numbers - whatever range I use.
Does anyone know how I can get a sequence of in-range, varied numbers?
For what I'm writing, it would also need to be seeded (the 'srandom'
command is what I'm currently using).
Thanks,
Matthew
- Raw text -