All signed
integer arithmetic uses a two's complement representation.
Bitwise operations on signed integral types follow
the rules that arise naturally from two's complement representation.
No sign extension takes place.
Right shifts on signed quantities are arithmetic.
For values of type int
,
Shifts outside the range 0 to 127 are undefined.
Left shifts of more than 31 give a result of zero.
Right shifts of more than 31 give a result of zero
from a shift of an unsigned value or positive signed value. They
yield –1 from a shift of a negative signed value.
For values of type long long
,
shifts outside the range 0 to 63 are undefined.
The remainder on integer division has the same sign
as the numerator, as required by the ISO C99 standard.
If a value of integral type is truncated to a shorter
signed integral type, the result is obtained by discarding an appropriate
number of most significant bits. If the original number is too large,
positive or negative, for the new type, there is no guarantee that
the sign of the result is going to be the same as the original.
A conversion between integral types does not raise
an exception.
Integer overflow does not raise an exception.
Integer division by zero returns zero by default.