Free Bitwise Calculator
Perform bitwise operations on integers and view results in decimal, hex, and binary.
How It Works
- Enter two numbers: Input the values you want to operate on — in decimal, binary (prefix 0b), or hexadecimal (prefix 0x).
- Select the operation: Choose AND, OR, XOR, NOT, left shift (<<), or right shift (>>).
- View the result: The output shows the result in decimal, binary, and hex simultaneously, with a bit-level visualization.
Why Use Bitwise Calculator?
Bitwise operations are fundamental in systems programming, cryptography, game development, graphics, networking, and embedded systems. Understanding how AND, OR, XOR, and shift operations manipulate individual bits is critical for tasks like setting/clearing flags, packing data into compact formats, and implementing efficient algorithms. This calculator shows the operation at the bit level so you can see exactly how each bit is affected.
Features
- All bitwise operators: AND (&), OR (|), XOR (^), NOT (~), left shift (<<), and right shift (>>).
- Multi-base input: Enter numbers in decimal, binary (0b...), or hexadecimal (0x...).
- Multi-base output: Results shown simultaneously in decimal, binary, and hexadecimal.
- Bit visualization: A visual bit grid shows which bits are set for each operand and the result.
- Signed/unsigned modes: Toggle between 8, 16, 32, and 64-bit integer widths.
Frequently Asked Questions
What is XOR used for in programming?
XOR (^) is used for toggling bits, simple encryption/obfuscation, swap operations without a temp variable, parity checks, and hash mixing. It returns 1 when bits differ and 0 when they are the same.
What is the difference between << and >>?
Left shift (<<) moves all bits to the left, equivalent to multiplying by powers of 2. Right shift (>>) moves bits right, equivalent to dividing by powers of 2. Arithmetic right shift preserves the sign bit; logical right shift fills with zeros.
How do I set or clear a specific bit?
To set bit n: value |= (1 << n). To clear bit n: value &= ~(1 << n). To toggle bit n: value ^= (1 << n). To check if bit n is set: (value & (1 << n)) !== 0.