It was thus said that the Great Chuck Guzis once stated:
On 02/20/2015 09:47 PM, Eric Smith wrote:
One can argue that a not-quite-C compiler for a
PDP-10 that supported
6-, 7-, and 8-bit character types as well as 18-bit and 36-bit
integers would be useful, but by definition it wouldn't actually be C.
What does the C standard say about the physical size of an int in bits,
versus the largest and smallest integer that can be held in those bits?
The constraints are:
sizeof(short) <= sizeof(int)
sizeof(int) <= sizeof(long)
sizeof(short) < sizeof(long)
And the minumum ranges are:
signed short -32,767 .. 32,767
signed int -32,767 .. 32,767
signed long -2,147,483,647 .. 2,147,483,647
unsigned short 0 .. 65,536
unsigned int 0 .. 65,536
unsigned long 0 .. 4,294,967,296
Of course, they can be larger. For instance, this is legal:
sizeof(short) == 2
sizeof(int) == 4
sizeof(long) == 8
By defintion, sizeof(char) == 1, and the minimum range is
signed char -127 .. 127
unsigned char 0 .. 255
Does C require 1's or 2's complement or can it
support sign-magnitude
integers?
Given the defined ranges, and the fact that signed overflow is undefined
behavior, I think C can be used on sign-magnitude and 1's complement
machines (however few those are). Unsigned overflow is defined to wrap
around to 0.
-spc