Re: NSInteger/NSUInteger Considerations (64 bit)
Re: NSInteger/NSUInteger Considerations (64 bit)
- Subject: Re: NSInteger/NSUInteger Considerations (64 bit)
- From: Jens Alfke <email@hidden>
- Date: Tue, 25 Mar 2014 16:55:33 -0700
On Mar 25, 2014, at 3:51 PM, Dave <email@hidden> wrote:
> Some of the files I am processing contain in excess of 500 Integer values and there can be around 3000 of these active at any one time.
That’s only a couple megabytes’ worth of address space (12MB if all of them are 64-bit.)
> I’m wondering if it would be better to define the properies are NSInteger/NSUIntger, or whether to define them as Int8/UInt8, or Int16/UInt16 or Int32/UInt32.
My opinion: in cross-platform code it’s annoying to work with types that are different sizes between platforms. It becomes all too easy to write code that compiles on one platform but generates warnings/errors on the other. It also raises the possibility that an operation might work on Mac OS, but overflow on iOS.
So if something is supposed to be a particular size (as seems to happen in your app) declare it as a type of that size. If you don’t care about the size and it won’t ever exceed a few billion, use `int` or `unsigned`. If it needs to hold huge values, or if you want to be really conservative, use `SInt64` or `UInt64`.
—Jens
_______________________________________________
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