Microchip Technology SW006021-1N 用户手册
Implementation-Defined Behavior
2012 Microchip Technology Inc.
DS52053B-page 481
C.5
INTEGERS (G.3.5)
C.5.1
The representations and sets of values of the various types of
integers (6.1.2.5)
integers (6.1.2.5)
C.5.2
The result of converting an integer to a shorter signed integer,
or the result of converting an unsigned integer to a signed
integer of equal length, if the value cannot be represented
(6.2.1.2)
or the result of converting an unsigned integer to a signed
integer of equal length, if the value cannot be represented
(6.2.1.2)
The low order bits of the original value are copied to the signed integer; or, all the low
order bits of the original value are copied to the signed integer.
order bits of the original value are copied to the signed integer.
C.5.3
The results of bitwise operations on signed integers (6.3)
The bitwise operations act as if the operand was unsigned.
C.5.4
The sign of the remainder on integer division (6.3.5)
The remainder has the same sign as the dividend. Table C-1 shows the expected sign
of the result of division for all combinations of dividend and divisor signs.
of the result of division for all combinations of dividend and divisor signs.
In the case where the second operand is zero (division by zero), the result will always
be zero.
be zero.
C.5.5
The result of a right shift of a negative-valued signed integral
type (6.3.7)
type (6.3.7)
The right shift operator sign extends signed values. Thus an object with the signed
int
int
value 0x0124 shifted right one bit will yield the value 0x0092 and the value 0x8024
shifted right one bit will yield the value 0xC012.
Right shifts of unsigned integral values always clear the MSb of the result.
Left shifts (<< operator), signed or unsigned, always clear the LSb of the result.
TABLE C-1:
INTEGRAL DIVISION
Dividend
Divisor
Quotient
Remainder
+
+
+
+
-
+
-
-
+
-
-
+
-
-
+
-