What is the maximum value of NSInteger?

喜欢而已 提交于 2019-11-28 07:12:52
Chuck

The maximum value of an NSInteger is NSIntegerMax.

The maximum value for an NSInteger is NSIntegerMax

(from Foundation Constants Reference)

Took me a little while for me to realise why I was getting a different value from NSIntegerMax when using NSUInteger!!

And the maximum for a NSUInteger is NSUIntegerMax

(also from http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Miscellaneous/Foundation_Constants/Reference/reference.html)

For 32-bit & 64 bit, there are two conventions: a)ILP32 b)LP64

The 32-bit runtime uses a convention called ILP32, in which integers, long integers, and pointers are 32-bit quantities. The 64-bit runtime uses the LP64 convention; integers are 32-bit quantities, and long integers and pointers are 64-bit quantities. These conventions match the ABI for apps running on OS X (and similarly, the Cocoa Touch conventions match the data types used in Cocoa), making it easy to write interoperable code between the two operating systems.

Table 1-1 all of the integer types commonly used in Objective-C code. Each entry includes the size of the data type and its expected alignment in memory. The highlighted table entries indicate places where the LP64 convention differs from the ILP32 convention. These size differences indicate places where your code’s behavior changes when compiled for the 64-bit runtime. The compiler defines the LP64 macro when compiling for the 64-bit runtime.

for 64 bit max range for NSInteger is : LONG_MAX : 9223372036854775807

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!