The two bitwise shift operators are
shift left (<<) and
shift right (>>). Each operator requires two operands.The first is an integer type operand that represents a bit pattern to be shifted. The second is an unsigned integer that indicates the number of displacements (i.e., whether the bits in the first operand will be shifted by 1 bit position, 2 bit positions, 3 bit positions, etc.). This value cannot exceed the number of bits associated with the word size of the operand.
Suppose a is an unsigned integer variable whose value is 0x6db7. The expression
b = a << 6;
will shift all bits of a six places to the left and assign the resulting bit pattern to the unsigned integer variable b. The resulting value of b will be 0x6dc0.
All of the bits originally assigned to a are shifted to the left 6 places..The rigtmost 6 bits positions are filled with 00 0000.
No comments:
Post a Comment