Re: NSInteger/NSUInteger Considerations (64 bit)
Re: NSInteger/NSUInteger Considerations (64 bit)
- Subject: Re: NSInteger/NSUInteger Considerations (64 bit)
- From: Dave <email@hidden>
- Date: Fri, 28 Mar 2014 13:47:41 +0000
On 28 Mar 2014, at 01:02, Jens Alfke <email@hidden> wrote:
>
> On Mar 27, 2014, at 3:34 PM, Roland King <email@hidden> wrote:
>
>> no difference, NSInteger, NSUInteger are just typedefs for underlying integral types
>
> On 32-bit iOS, int and NSInteger are both 32-bit, so there’s no difference.
> On Mac OS (and 64-bit iOS), int is 32-bit but NSInteger is 64-bit. I don’t actually know whether there’s any performance difference between 32- and 64-bit math on 64-bit processors, but you can’t just hand-wave the question away.
>
I know, that’s why I asked which is fastest.
> What _is_ different is that 64-bit numbers occupy twice as much space in the CPU caches, so only half as many will fit. Cache misses are orders of magnitude more expensive than integer math operations, so that’s the more significant issue.
The values will be held inside the object properties as int or whatever. I was wondering if I should write getters to return it as an UIInteger, e.g. hold the real int value in an iVar and have the associated property getter coerce it to NSInteger on return.
That way, it will only hold the values as 64 bit when they are being worked on.
Not sure which is more effecient in terms of speed or if it matters that much.
Cheers
Dave
_______________________________________________
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