Re: Best way to get a non-repeating random number?
Re: Best way to get a non-repeating random number?
- Subject: Re: Best way to get a non-repeating random number?
- From: WT <email@hidden>
- Date: Tue, 14 Apr 2009 02:17:11 +0200
On Apr 14, 2009, at 1:57 AM, Uli Kusterer wrote:
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.
Sorry to nitpick, but no, it *isn't* a random number generator. It's a
*pseudo*-random number generator. Using the same seed in two different
invocations will result in the exact same sequence of generated
numbers for both invocations. So, technically, even though the
generated numbers are as close to being random as one can get by non-
physical (ie, algorithmic) means, the generator cannot be called a
random number generator.
The remainder of your post is, of course, completely correct. It's
perfectly possible for a random sequence (even a *truly* random
sequence, such as one generated by physical means) to have any number
of repeating numbers in succession.
Wagner
_______________________________________________
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