Similar questions already asked, but please can anyone explain to me why this code…
NSInteger hexInt = 0x80000505;
NSLog(@"%d, %#x", hexInt, hexInt);
prints out -2147482363, 0x80000505 while 0x80000505 equals to 2147484933 and not to -2147482363 ?
Thank you…
NSInteger is defined as int (
typedef int NSInteger) and 2147484933 overflows int maximal value (on 32 bit systems, where the range of int is −2,147,483,648 to +2,147,483,647), because as you can see, the highest bit is set in 0x80000505, so 0x80000505 is a negative number.