Quote Originally Posted by flp1969 View Post
Even more: The pre-processor "code" below will always result in CHAR_BIT == 8:
Code:
#ifndef CHAR_BIT
#if ~0 << 8
#define CHAR_BIT 8
#elif ~0 << 7
#define CHAR_BIT 7
#elif ~0 << 6
#define CHAR_BIT 6
#elif ~0 << 5
#define CHAR_BIT 5
#else
#define CHAR_BIT 4
#endif
#endif
Because ~0 will be, at least, of "int" type as per ISO 9989 6.4.4.1.5 (and INT_MIN is 15 bits long [plus the sign bit] as in 5.2.4.2.1, pointed by John). So since 'int' is, at least, 16 bits long, ~0 << 8 will always be "true" (not zero).
Oh really? You might wanna read this article then:
Word (computer architecture) - Wikipedia