Bit Manipulator
Manipulate individual bits within a number. Set bits to 1, clear bits to 0, toggle bits, or check if specific bits are set. Visualize the binary representation with an interactive bit display. Perfect for learning binary operations and debugging bit-level code.
Bit Manipulator
Position 0 is the rightmost (least significant) bit
Binary Representation
00000000000000000000000000101010
Interactive Bit View
Click on a bit to toggle it. Highlighted bit is the selected position.
Bit Operations at Position 0
Get Bit
0
Value at position 0
Set Bit (click to apply)
43
Set bit 0 to 1
Clear Bit (click to apply)
42
Set bit 0 to 0
Toggle Bit (click to apply)
43
Flip bit 0
Operation Reference
Get Bit
(n >> position) & 1
Set Bit
n | (1 << position)
Clear Bit
n & ~(1 << position)
Toggle Bit
n ^ (1 << position)
FAQ
How do I set a specific bit?
To set bit n to 1, use OR with a mask: number | (1 left-shift n). For example, to set bit 3 of value 5 (0101), compute 5 | 8 = 13 (1101). This tool does this automatically.
How do I clear a specific bit?
To clear bit n (set to 0), use AND with an inverted mask: number & ~(1 left-shift n). This keeps all bits except position n, which becomes 0.
What are bit flags used for?
Bit flags efficiently store multiple boolean values in a single integer. Each bit represents a true/false option. Common examples include file permissions, feature toggles, and game state flags.