DSAverse
Bit Manipulation
Loading Bit Manipulation...
Binary Register
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
bit 15bit 0
Initializing Sorting Algorithms...
Sorting
Trees
Graphs
Preparing interactive visualizations...
Bit Manipulation
Loading Bit Manipulation...
Binary Register
Check if a number is a power of two with a single bitwise AND. Powers of two have exactly one set bit — n & (n−1) == 0 in O(1).
An interactive step-by-step visualization for Power of Two is currently being built. You will be able to enter any number and see how n & (n−1) reveals whether exactly one bit is set.
Back to Bit Manipulation