Re: Seeding random() randomly
Re: Seeding random() randomly
- Subject: Re: Seeding random() randomly
- From: Chase Latta <email@hidden>
- Date: Thu, 26 May 2011 20:10:05 -0700
unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] * 10000.0);
You are trying to set seed to a value that is something like
3,281,585,690,000; seed cannot handle this value so it will be set to
4294967295, at least on my machine.
You are using the same seed each time you run the program so you are
getting the same values. Try getting rid of the "* 10000.0".
Chase
On Thu, May 26, 2011 at 7:15 PM, Kevin Bracey <email@hidden> wrote:
> I think this was from some programming book I have, sorry I can site it:
>
> srandom(time(NULL));
>
> cheers
> Kevin
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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