As the title suggests, I am curious about how an unsigned int
(or things like NSUInteger
, u_int_blah
, but I assume these are all
In answer to your first code example, the loop will compile (though will raise a warning if you are compiling with gcc and have the -Wno-sign-compare flag). Running it, however, will generally result in the loop not running at all since most systems use Two's complement (http://en.wikipedia.org/wiki/Two%27s_complement) which means -10 is the same as 4294967286 (assuming 4 byte integers but in general 2*INT_MAX - 10) which is greater than 5. In general, I recommend reading up on Two's complement as it will probably answer all your questions on the matter.