• 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: Jason Foreman <email@hidden>
  • Date: Wed, 25 Nov 2009 11:47:49 -0600

On Nov 25, 2009, at 11:26 AM, Derek Gaston wrote:

> This piece of code should generate 100 random numbers between 0 and 1... I am expecting that they be fairly spaced out as well...

What basis do you have for this expectation?  Is it spelled out in any specification or standard somewhere?

You're seeding the RNG with a monotonically increasing seed, and getting what looks like monotonically increasing starting values for your random sequences.  The fact that you get what you expect on Linux seems to be purely coincidental.


> 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 ;-)


I think you're going to have to explain why you feel reseeding is necessary.  You probably shouldn't be doing it.


Jason


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: rand() and srand() broken?
      • From: Derek Gaston <email@hidden>
References: 
 >rand() and srand() broken? (From: Derek Gaston <email@hidden>)

  • Prev by Date: Re: rand() and srand() broken?
  • Next by Date: Re: rand() and srand() broken?
  • Previous by thread: Re: rand() and srand() broken?
  • Next by thread: Re: rand() and srand() broken?
  • Index(es):
    • Date
    • Thread