• 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: Best way to get a non-repeating random number?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to get a non-repeating random number?


  • Subject: Re: Best way to get a non-repeating random number?
  • From: "Luca C." <email@hidden>
  • Date: Tue, 14 Apr 2009 12:26:16 +0200

2009/4/14 Uli Kusterer <email@hidden>

> On 14.04.2009, at 01:44, Luca C. wrote:
>
>> You can put every (unsigned) value you want in there, though in
>> general it's used passing (unsigned)time(NULL) as parameter.  This way
>> you'll always get a different int.
>>
>
>
>  No you won't. It's a *random* number generator. The seed simply means you
> get a different sequence of random numbers. However, random really means
> RANDOM. I.e. it's perfectly possible to get the same number three times in a
> row during a sequence. That would still be random.


Hmm...

Given a seed, rand() will create always the same sequences for that seed.
 But if the seeds changes all the time, you'll always get different
sequences, as it's obvious.  You'll get the same sequences only if you pass
the same seed again, otherwise you'll get some other sequences.
  In practical use of rand() I have never seen what you're saying, though
it's possible.  But that doesn't imply that you'll get every time the same
number consequentally in a sequence, that's very rare case if you use
different seeds, very rare.
  Am i wrong?

--Luca C.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Best way to get a non-repeating random number?
      • From: WT <email@hidden>
    • Re: Best way to get a non-repeating random number?
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Best way to get a non-repeating random number? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Best way to get a non-repeating random number? (From: "Luca C." <email@hidden>)
 >Re: Best way to get a non-repeating random number? (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Exit an Application
  • Next by Date: Re: Best way to get a non-repeating random number?
  • Previous by thread: Re: Best way to get a non-repeating random number?
  • Next by thread: Re: Best way to get a non-repeating random number?
  • Index(es):
    • Date
    • Thread