Mail Archives: djgpp/1997/11/26/19:46:39
Deltaman wrote:
>
> Are there any good random routines to substitute random()?
> It returns too predictable values to be of real value to me. Even with a
> random seed it still returns the same values several times in a row.
> Does anyone know of a way to get more random numbers?
This is the first time anybody has reported any such problem with
random(). Are you sure you are seeding it? The clock value is a good
seed to use:
#include <stdlib.h>
#include <time.h>
srandom( (int) time( NULL ) );
...
x = random() % 100;
Also remember, you only need to use srandom() once.
If this doesn't help, please post some more details, like some sample
program code that generates non-random numbers. The period of random()
is supposed to be at least 2^32.
--
---------------------------------------------------------------------
| John M. Aldrich | "A woman is not property, and hus- |
| aka Fighteer I | bands who think otherwise are living |
| mailto:fighteer AT cs DOT com | in a dreamworld." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -