On 31 Jan 2012 at 21:48, Fred Cisin wrote:
In K&R C (I don't know from ANSI), it was
recommended that an int be
whatever type was easiest to deal with. A short int could be the same
or smaller. A long int could be the same or larger. It was explicitly
stated that the only given was that the sizeof long int could not be
SMALLER than the size of int, and the sizeof in could not be smaller
than the sizeof short int.
int and unsigned int are often the same size, but that was NOT
required.
What about the numeric results of a shift on an int? I am aware of
more than one system that handles ints as a special case of float;
i.e., the int may be 64 bits long, but it's composed of a 16 bit
exponent followed by a 48 bit mantissa. It would seem that shifting
one of those would produce some "interesting" results.
Similarly, sign-magnitude integer representations will give very
different results after a shift than will shifting the normal two/s
complement int.
--Chuck