On Apr 13, 2009, at 8:36 PM, Michael Ash 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.
Technically, I'm pretty sure you will always get a different int.
rand() is a crappy, crappy random number generator, and I would guess
that its algorithm can never return the same number twice in a row.

(If anyone is wondering what the alternatives are, use random() instead.)

arc4random() is also pretty decent, if you need cryptographically strong random numbers.

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to