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 20:31:30 +0000
On 25 Nov 2009, at 20:18, Clark Cox wrote:
>> Indeed... note that this wasn't about passing the _same_ value... it was about passing similar values to srand... like singularly increasing integers...
>
> I was responding specifically to:
>
> "Are you (and everyone else that replied) trying to tell me that the
> first number out of rand() (after reseeding) should always be the
> predictable?"
Having read the rest of this thread, I think Derek meant predictable in the sense that given the first value generated after seeding the generator with a value N, the values generated after seeding with N - 1 or N + 1 are "too predictable".
His problem really boils down to the fact that rand() makes no guarantees on that front; indeed, nor do most other PRNGs. It's quite normal for even the highest quality PRNG to be seeded using a simpler PRNG when you call a function like srand(), so comparing the first generated value (or even the Nth generated value) is not likely to be a great plan.
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