Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Iterate through all 32 bit positions. For each position, extract the lowest bit of n with n & 1, shift the result left by 1 and OR in the extracted bit, then right-shift n. This builds the reversed number one bit at a time.
Each iteration moves one bit from the least significant end of the input to the most significant end of the result, effectively mirroring the entire 32-bit representation.
Updated Feb 2026