Bitwise Left Shift and Right Shift Operators: <<, >>
shift-expression :
additive-expression
*shift-expression * **<<**additive-expression
*shift-expression * **>>**additive-expression
The bitwise shift operators shift their first operand left (<<) or right (>>) by the number of positions the second operand specifies.
For more information, see bitwise-AND, bitwise-exclusive-OR, bitwise-inclusive-OR, and one's complement.
Example
In the following example, the right shift operator moves the data bits two positions to the right, thus changing the value of nNumA
:
// Example of the bitwise right shift operator
int nNumA=8; // beginning value is 8
nNumA >> 2; // ending value is 2