Re: strange behavior of random numbers with gtkmm
- From: Eric Wolf <eric boese-wolf eu>
- To: Alexey Savartsov <asavartsov gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: strange behavior of random numbers with gtkmm
- Date: Tue, 15 Jun 2010 21:03:25 +0200
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]