Re: Random Number
Re: Random Number
- Subject: Re: Random Number
- From: Jens Bauer <email@hidden>
- Date: Thu, 28 Feb 2002 20:57:05 +0100
Hi Shaun,
On Thu, 28 Feb, 2002, Shaun Chu <email@hidden> wrote:
>
Sorry if this sounds like a dumb question, but how do I get a truly random
>
number in Cocoa?
Unfortunately, the only computer that had a true random generator was the
Sinclair ZX81.
This machine used processor-noise for random-generation, and it worked
very well.
If you need something less sophisticated, you can use rand() which is the
worst choice,
or you could grab a timer now and then, insert some of the low-order bits
into a longword, multiply this by 31415927, keep this as the seed value,
and return (the seed bitshifted 8 to the right)
Finally, you could go and use the Cocoa API's random, which would
probably be preferrable.
Love,
Jens
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.