What about the numeric results of a shift on an int?
[#4] The result of E1 << E2 is E1 left-shifted E2 bit
positions; vacated bits are filled with zeros. If E1 has an
E2
unsigned type, the value of the result is E1?2 , reduced
modulo one more than the maximum value representable in the
result type. If E1 has a signed type and nonnegative value,
E2
and E1?2 is representable in the result type, then that is
the resulting value; otherwise, the behavior is undefined.
[#5] The result of E1 >> E2 is E1 right-shifted E2 bit
positions. If E1 has an unsigned type or if E1 has a signed
type and a nonnegative value, the value of the result is the
integral part of the quotient of E1 divided by the quantity,
2 raised to the power E2. If E1 has a signed type and a
negative value, the resulting value is implementation-
defined.
Unsigned ints, by definition, work as if they were simple binary
(two's-complement, though that's not relevant for shifts).
Similarly, sign-magnitude integer representations will
give very
different results after a shift than will shifting the normal two/s
complement int.
Only for negative values, in which case the result can be whatever the
implementation finds convenient (undefined or implementation-defined).
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at
rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B