same random sequence generation

Linas Vepstas linas at austin.ibm.com
Fri Mar 31 19:16:11 CEST 2006


On Fri, Mar 31, 2006 at 03:02:33PM +0200, Gergely CZUCZY wrote:
> every time i run the application, it generates the very same
> random sequence, however, it had been seeded with a different
> seed.

Are you sure? 

> seed = rand();

If called only once, rand will always return the same number.

> QueryPerformanceCounter(&l);
> seed ^= l.LowPart;

Not clear to me that the perf counter returns a different value
every time.

This a disasterously bad algorithm for generating entropy.

Unix boxes have a built in entropy pool, constantly stirred with 
stochastic data from the ethernet, keyboard and mouse.  Its 
accessible with the /dev/random device.  Perhaps Windows 
has this concept too.

--linas



More information about the gmp-discuss mailing list