Jens Gustedt's Blog  September 21, 2010  Anatomy of integer
types in C  Filed under: C99, integers — Jens Gustedt @ 04:06
Integer types in C may present subtle traps (sic!) that many
people are not aware of when doing seemingly simple things like
~0 or  (1 << (sizeof(int)*CHAR_BIT - 1))  Most times, on almost
all processors these will produce the desired effects, but
sometimes such a code will fail, crash, spit a lot of warnings.
I will try to analyze this a bit, to show what may go wrong,
here, and how you can get around a lot of possible problems.
This is a discussion that is a bit involved, you should know a
bit of things about integer types and how to use them.  The
simple case: unsigned char  The first and only case that is
guaranteed to be simple are unsigned char. On most commodity
architectures this will correspond to uint8_t, but to be most
general let us assume here that it has CHAR_BIT >= 8 bits. The
C99 standard enforces that this type takes values from 0 to
UCHAR_MAX = M - 1 where M, the modulu