• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: rand() and srand() broken?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >rand() and srand() broken? (From: Derek Gaston <email@hidden>)
 >Re: rand() and srand() broken? (From: Jason Foreman <email@hidden>)
 >Re: rand() and srand() broken? (From: Derek Gaston <email@hidden>)
 >Re: rand() and srand() broken? (From: Clark Cox <email@hidden>)
 >Re: rand() and srand() broken? (From: Derek Gaston <email@hidden>)
 >Re: rand() and srand() broken? (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: rand() and srand() broken?
  • Next by Date: Re: Open Source Releases
  • Previous by thread: Re: rand() and srand() broken?
  • Next by thread: Re: [APPL:DarwinDev] Re: rand() and srand() broken?
  • Index(es):
    • Date
    • Thread