Reverse Bits
easyReverse bits of a 32-bit unsigned integer
Reverse Bits
Key Insight
Extract LSB with (n & 1), shift result left, OR to add bit. Repeat 32 times.
Step 1Input
input
13
=0
0
0
0
1
1
0
1
76543210
8-bit: 00001101
Reverse bits of 13 (binary: 1101)
1 / 5