Re: strange behavior of random numbers with gtkmm



Alexey Savartsov <asavartsov gmail com> writes:

> The problem is that you always calling srand with same seed parameter. So you always get same random sequence.
>
> Usually, srand called with the current time value like:
>
> srand(time(0)); 
>
> May be you need type casting of time() return value - follow compiler warnings there.

Another possibility —at least in linux— is reading some bytes 
from /dev/urandom and use these as seed.

Maybe random/srandom should be used instead of rand, because
man 3 advertise them as being more random than rand (tm). 
Whatever this means ...

Eric


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]