Re: Variable type representations
Re: Variable type representations
- Subject: Re: Variable type representations
- From: Quincey Morris <email@hidden>
- Date: Fri, 11 Mar 2016 12:55:41 -0800
- Feedback-id: 167118m:167118agrif8a:167118sRg9yomjMA:SMTPCORP
On Mar 11, 2016, at 12:43 , Carl Hoefs <email@hidden> wrote:
>
> Q1: How can 'long' and 'long long' have the same 8-byte representation?
Go complain to the gods of C. That language is responsible for the concept:
sizeof (int) <= sizeof (long) <= sizeof (long long)
Note the “=“ signs. (It’s all about getting the “natural-est” variable size on heterogeneous platforms.)
> Q2: How to get an unsigned long int value from an NSString? Use NSInteger?
For any reasonable (i.e. 64-bit) OS X app, just use ‘unsignedIntegerValue’ and cast the result. If you want compatibility with 32-bit architecture, use ‘unsignedLongLongValue’ and cast the result. (You can use the latter in either case, but it’s a bit of a mouthful.)
_______________________________________________
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