Limits
System limits for various types can be found in limit.h.
@import <limits.h> // ... NSLog(@"CHAR_MIN: %c", CHAR_MIN); NSLog(@"CHAR_MAX: %c", CHAR_MAX); NSLog(@"SHRT_MIN: %hi", SHRT_MIN); // signed short int NSLog(@"SHRT_MAX: %hi", SHRT_MAX); NSLog(@"INT_MIN: %i", INT_MIN); NSLog(@"INT_MAX: %i", INT_MAX); NSLog(@"LONG_MIN: %li", LONG_MIN); // signed long int NSLog(@"LONG_MAX: %li", LONG_MAX); NSLog(@"ULONG_MIN not defined, it's always zero: %lu", 0); NSLog(@"ULONG_MAX: %lu", ULONG_MAX); // unsigned long int NSLog(@"LLONG_MIN: %lli", LLONG_MIN); // signed long long int NSLog(@"LLONG_MAX: %lli", LLONG_MAX); NSLog(@"ULLONG_MIN not defined, it's always zero: %llu", 0); NSLog(@"ULLONG_MAX: %llu", ULLONG_MAX); // unsigned long long int
Native Types
char
'a', '\n'
double
double is guaranteed to be at least 64-bit. All numeric constants are by default assumed to be a double unless
specified with either am f or F.
12.31 // minimum 64-bit double 12.31f // minimum 32-bit float 12.31F // minimum 32-bit float
NSLog Formats
| Type | Constant Examples | NSLog Format |
|---|---|---|
char |
‘a’, ‘\n’ | %c |
short int |
%hi, %hx, %ho |
|
unsigned short int |
%hu, %hx, %ho |
|
int |
17, -99, 0xFFAE, 0878 | %i, %x, %o |
unsigned int |
17u, 101U, OXFFu | %u, %x, %o |
long int |
17L, -2998, OxffffL | %li, %lx, %lo |
unsigned long int |
17UL, -100ul, OxffeeUL | %li, %lx, %lo |
long long int |
0xe5e5e5e5LL, 500ll | %lli, %llx, %llo |
unsigned long long int |
17ull, oxffefULL | %llu, %llx, %llo |
float |
12.3f, 3.1e-5f, 0×1.5p10, 0×1P-1 | %f, %e, %g, %a |
double |
12.34, 3.1e-5, 0×.1p3 | %f, %e, %g, %a |
long double |
12.34l, 3.1e-5l | %Lf, %Le, %Lg |
id |
nil | %p |