3 ms·
The standard requires that "int" be able to represent from -32767 to +32767. Unless "byte" is redefined to contain a different number of bits, this means that s
by jedbrown 15y ago
The standard requires that "int" be able to represent from -32767 to +32767. Unless "byte" is redefined to contain a different number of bits, this means that sizeof(int) >= 2. Similarly, long has a range that requires at least 32 bits.
- Erwin 15y agosizeof(char) is 1 per definition and also one byte, but not necessarily 8 bits. Apparently some DSPs cannot address an 8-bit quantity -- they're not easy to find but I've found a comp.lang.c posting where Jack Klein mentions a 32-bit Sharp DSP with CHAR_BIT = 32 (so sizeof(char) == sizeof(int) == 1 !) and a Texas Instruments TMS32F28xx DSP with a 16 bit CHAR_BIT. On such a system, C99 might not define int8_t but you could use int8_least8_t. My guess is that they are more common than 64-bit ints but they might be supported by their own weird C Compiler/toolchain.
- caf 15y agoThe interesting thing about such architectures is that the common stdio idiom: int c; while ((c = getchar()) != EOF) { does not work properly on them.