On Thu, May 26, 2011 at 9:15 PM, Dave Keck davek...@gmail.com wrote:
I'm using random(), but every time I run my app I get the same sequence,
despite having this code in my app delegate's -appDidFinishLaunching method.
Clearly I'm not seeding it right, though I can't see why - I get a
On May 26, 2011, at 8:00 PM, Graham Cox wrote:
I'm using random(), but every time I run my app I get the same sequence,
despite having this code in my app delegate's -appDidFinishLaunching method.
Clearly I'm not seeding it right, though I can't see why - I get a different
value for seed
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 5/26/11 9:52 PM, Graham Cox wrote:
On 27/05/2011, at 2:42 PM, Clark Cox wrote:
No. 'unsigned' is the same size on both 32- and 64-bit The only
built-in types that are different between 32- and 64-bits are:
signed long long (which is
On May 26, 2011, at 10:32 PM, Jens Alfke wrote:
On May 26, 2011, at 7:15 PM, Kevin Bracey wrote:
srandom(time(NULL));
It’s never a good idea to seed a RNG with something guessable like this. (An
old exploit against the Netscape browser’s SSL implementation was made
possible in part
Regarding format specifiers, there is the String Format Specifiers section of
the String Programming Guide in Apple's Developer Documentation. Here is a
link to the web version:
On May 26, 2011, at 9:04 PM, Scott Ribe wrote:
It’s never a good idea to seed a RNG with something guessable like this.
Not all applications of random() have anything to do with security…
Agreed. But I didn’t say it was always a bad idea, just never a good one. :)
Seeding with something
I'm using random(), but every time I run my app I get the same sequence,
despite having this code in my app delegate's -appDidFinishLaunching method.
Clearly I'm not seeding it right, though I can't see why - I get a different
value for seed every time. What gives?
unsigned seed =
I'm using random(), but every time I run my app I get the same sequence,
despite having this code in my app delegate's -appDidFinishLaunching method.
Clearly I'm not seeding it right, though I can't see why - I get a different
value for seed every time. What gives?
unsigned seed =
On May 26, 2011, at 8:00 PM, Graham Cox wrote:
I'm using random(), but every time I run my app I get the same sequence,
despite having this code in my app delegate's -appDidFinishLaunching method.
Clearly I'm not seeding it right, though I can't see why - I get a different
value for seed
On May 26, 2011, at 18:00, Graham Cox wrote:
unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] *
1.0);
NSLog(@launched, seed = %ld, seed );
Also, be careful here, because %ld is the wrong format specifier for type
'unsigned'. Whether it logs the
On May 26, 2011, at 6:15 PM, Dave Keck wrote:
I'm not sure what your problem is, but I believe arc4random() has superseded
random() for a while now.
Incorrect. There are many reason to have a seedable PRNG, the least of which is
the ability to reasonably debug the randomness. That an
On 27/05/2011, at 11:23 AM, Quincey Morris wrote:
On May 26, 2011, at 18:00, Graham Cox wrote:
unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] *
1.0);
NSLog(@launched, seed = %ld, seed );
Also, be careful here, because %ld is the wrong format
On May 26, 2011, at 8:32 PM, Graham Cox wrote:
On 27/05/2011, at 11:23 AM, Quincey Morris wrote:
On May 26, 2011, at 18:00, Graham Cox wrote:
unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] *
1.0);
NSLog(@launched, seed = %ld, seed );
Also, be
On 27/05/2011, at 11:53 AM, Ken Thomases wrote:
%u
I'm confused about how to correctly write format specifiers for both 32 and
64-bit runtimes. The 64-bit porting guide doesn't spell it out (yet you end
up with code peppered with warnings that you should examine the use of the
format
I think this was from some programming book I have, sorry I can site it:
srandom(time(NULL));
cheers
Kevin
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the
unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] * 1.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
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 5/26/11 6:00 PM, Graham Cox wrote:
I'm using random(), but every time I run my app I get the same
sequence, despite having this code in my app delegate's
-appDidFinishLaunching method. Clearly I'm not seeding it right,
though I can't see why -
I've seen gnu documentation for srandom that suggest the equivalent of Kevin's
suggestion, namely srandom(time(0)). Not sure if using the NSDate has any
advantage over a call to time() and it would avoid this type of thing (gnu is
likely to ensure time() and srandom() work correctly together).
On May 26, 2011, at 7:15 PM, Kevin Bracey wrote:
srandom(time(NULL));
It’s never a good idea to seed a RNG with something guessable like this. (An
old exploit against the Netscape browser’s SSL implementation was made possible
in part by doing exactly that.)
All you have to do is call
On May 26, 2011, at 9:32 PM, Jens Alfke wrote:
It’s never a good idea to seed a RNG with something guessable like this.
Not all applications of random() have anything to do with security...
--
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice
On 27/05/2011, at 1:16 PM, Conrad Shultz wrote:
I'm pretty sure your problem has to do with overflowing your data types.
unsigned is getting treated as unsigned int, which will be too
small to hold the value after you, for some reason I'm not clear on,
multiply by 1.
When I wrote some
On Thu, May 26, 2011 at 9:30 PM, Graham Cox graham@bigpond.com wrote:
I should mention this is in a 64-bit build, so doesn't that mean that
'unsigned' is 64 bits?
No. 'unsigned' is the same size on both 32- and 64-bit The only
built-in types that are different between 32- and 64-bits are:
On 27/05/2011, at 2:42 PM, Clark Cox wrote:
No. 'unsigned' is the same size on both 32- and 64-bit The only
built-in types that are different between 32- and 64-bits are:
signed long
long (which is really the same as signed long)
unsigned long
and any pointer type
All other built-in
23 matches
Mail list logo