I want to write a program which reverses the bits of an integer. Ex 11000101 to 10100011 I know how to solve this using a loop, but I came across solutions that do it us
1100 0101
>> 4 means we are shifting the bits by 4 to the right:
>> 4
0000 1100
<< 4 means we are shifting the bits by 4 to the left:
<< 4
0101 0000
| is the or operation:
|
0000 1100 ↓↓↓↓ ↓↓↓↓ | 0101 0000 --------- 0101 1100
As you see, the program changed the two blocks of 4 bits.