Bit Operations
Shifts
- shift a word x bits to the right or left:
- 0110 shift left by 1 is 1100
- 0110 shift right by 1 is 0011
- In C++ shifts are expressed using <<,>>
- unsigned int y = x<ɝ, z = x>ɯ
- means y is the value of x shifted 5 to left, and z is x shifted 3 to the right.
- One application is multiplication/division by powers of 2.