Re: NSUInteger in for-loop?
Re: NSUInteger in for-loop?
- Subject: Re: NSUInteger in for-loop?
- From: j o a r <email@hidden>
- Date: Sun, 14 Sep 2008 21:38:37 -0700
On Sep 14, 2008, at 9:15 PM, Alex Reynolds wrote:
I'm wondering if I'm using unsigned integers (specifically
NSUInteger) properly or not.
I was under the impression that unsigned integers run from 0 to
MAX_INT, but when I use them in a "for" loop within these bounds,
the loop does not seem to always obey these constraints.
For example:
for (NSUInteger counter = 5; counter >= 0; --counter)
{
NSLog(@"NSUInteger: %d", counter);
}
keeps running well after the "counter" variable turns negative:
NSUInteger runs from 0 -> NSUIntegerMax.
This is how you print a NSUInteger:
NSLog(@"NSUInteger: %lu", ((unsigned long)counter));
j o a r
_______________________________________________
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