Define Bitwise-Shift Operators?
The shift operators perform suitable shift by operator on the right to the operator on the left. The right operator should be positive. The vacated bits are filled with zero that is there is NO wrap around.
For example: x << 2 shifts the bits in x by 2 places to the left.
So:
if x = 00000010 (binary) or 2 (decimal)
then:
or
0 (decimal)
Also: if x = 00000010 (binary) or 2 (decimal)
8 (decimal)
Consequently a shift left is equivalent to a multiplication by 2. Likewise a shift right is equal to division by 2
NOTE: Shifting is much faster in comparison of actual multiplication (*) or division (/) by 2 thus if you want fast multiplications or division by 2 use shifts.