Re: rand() and srand() broken?
Re: rand() and srand() broken?
- Subject: Re: rand() and srand() broken?
- From: Alastair Houghton <email@hidden>
- Date: Wed, 25 Nov 2009 17:44:10 +0000
On 25 Nov 2009, at 17:26, Derek Gaston wrote:
> This is actually indicative of what we actually do in one of our applications (I know it doesn't usually make much sense to reseed all the time... but you're just going to have to trust me that it's necessary in our case ;-)
It's wrong. Whether you think it's necessary or not, it's just plain wrong. Pseudo-random number generators usually don't guarantee good output if you re-seed them all the time.
Perhaps you should explain the problem that you think requires reseeding every time and someone can help you to design your algorithm better?
You might also want to try the random() function rather than the rand() function, since it's usually a better generator. I haven't looked to see whether that's true on OS X, but it normally has a better range and often uses a better algorithm behind the scenes too.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden