AboutShiftOperation:
1.ShiftThe number of two operations must be an integer expression. The integer is upgraded on both sides of the Operation number. The overall Type of the expression is the same as the number of left operations after the upgrade;
2. LeftShiftExp1 <exp2 expression causes the exp1 bit to be moved left by the number specified by expr2 and 0 at the low end;
3. RightShiftOperator> and leftShiftThe operators are asymmetrical. Returns the left operand.ShiftDepends on the type of the left operand:
(1) If the left operand is unsigned (or a non-negative number with a symbol), the left operand is moved to 0;
(2) If the left operand is a negative number with a symbol, the implementer can add 0 or insert the leftmost displacement of the left operand (usually fill the symbol bit ).
# Include <stdio. h>
Int main (INT argc, char ** argv)
{
Unsigned char V1 = 3;
Unsigned char v2 = 0x03;
Unsigned char V3 = 0;
V3 = V1 <2;
Printf ("First time, V1 = % d/N", V1 );
Printf ("First time, V3 = % d/N", V3 );
V3 = V2 <2;
Printf ("Sec time, V2 = 0x % x/N", V2 );
Printf ("Sec time, V3 = 0x % x/N", V3 );
}
Output result:
First time, V1 = 3
First time, V3 = 12
SEC time, V2 = 0x3
SEC time, V3 = 0xc
The results indicate two problems:
1. Shift V1, which cannot be changed;
2. If you want to use the value after the shift, you must make the shift to the right and assign the value to other variables or itself.