EasyBit Manipulation

Reverse Bits

Given a 32-bit unsigned integer n, reverse the bits of its binary representation (bit 0 becomes bit 31, bit 1 becomes bit 30, …) and return the result.

n = 00000000000000000000000000010101 (21)→ 2818572288 (10101000000000000000000000000000)

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Variables

The data structures the code is building

Bits

Bit 31 on the left; lines show where each bit goes

Time and space complexity

The input is always 32 bits wide. The highlighted row is the solution being traced.

Keyboard: ← → step, Space play or pause. n as a decimal from 0 to 4294967295, or as 32 binary digits.