Question

Im looking for a list of all the scalar data types in Objective C, complete with their ranges (max/min values etc).

Sorry for the simple question, Im just really struggling to find anything like this.

Was it helpful?

Solution

  • int An integer value between +/– 2,147,483,647.
  • unsigned int An integer value between 0 and 4,294,967,296.
  • float A floating point value between +/– 16,777,216.
  • double A floating point value between +/– 2,147,483,647.
  • long An integer value varying in size from 32 bit to 64 bit depending on architecture.
  • long long A 64-bit integer.
  • char A single character. Technically it’s represented as an int.
  • BOOL A boolean value, can be either YES or NO.
  • NSInteger When compiling for 32-bit architecture, same as an int, when compiling for 64-bit architecture,+/– 4,294,967,296.
  • NSUInteger When compiling for 32-bit architecture, same as an unsigned int, when compiling for 64-bit architecture, value between 0 and 2^64

Source.

OTHER TIPS

  1. char : A character 1 byte
  2. int :An integer — a whole number 4 bytes
  3. float : Single precision floating point number 4 bytes
  4. Double : Double precision floating point number 8 bytes
  5. short : A short integer 2 bytes
  6. long : A double short 4 bytes
  7. long long : A double long 8 bytes
  8. BOOL : Boolean (signed char) 1 byte

For more on sizes check this post

Integer types are signed 2's complement or unsigned and the standard C variations are provided (char, short, int, long, long long and unsigned variants of these, see C types on Wikipedia), sizes may vary dependent on 32-bit & 64-bit environments - see 64-bit computing.

BOOL is an Objective-C special and is defined as signed char, while it can take any value a signed char can the constants NO and YES are defined for use. The C9X type _Bool(aka bool) is also provided.

float & double are IEEE 32-bit & 64-bit floating point - see Wikipedia for ranges.

Standard macro contants are provided for the minimum and maximum of all the types, e.g. INT_MAX for int - again see C types on Wikipedia for these.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top