Accepted formats: decimal, binary (0b...), hex (0x...), octal (0o...).
For shift operators, only the lowest 5 bits of B are used (0–31).
What is a bitwise operator calculator?
A bitwise operator calculator helps you perform operations directly on binary digits (bits). Instead of doing normal arithmetic like addition or multiplication, bitwise operators compare and transform each bit in a number. This is especially useful in programming, system design, cryptography, compression, and low-level data handling.
This calculator accepts common number formats and shows your result in multiple representations so you can quickly understand how each operation changes the underlying bits.
How to use this calculator
- Enter Operand A.
- Select a bitwise operator.
- Enter Operand B (unless using
~A, which is unary). - Click Calculate.
- Review the result in signed decimal, unsigned decimal, hexadecimal, and 32-bit binary.
Supported operators
AND (&)
Returns 1 only where both corresponding bits are 1. This is commonly used for masking specific bits.
OR (|)
Returns 1 where at least one of the compared bits is 1. Useful for combining flags.
XOR (^)
Returns 1 where bits differ. Useful for toggling bits and for quick difference checks.
NOT (~)
Flips every bit in a single value. All 0s become 1s and all 1s become 0s.
Left shift (<<)
Shifts bits left and fills in zeros on the right. This often multiplies by powers of two (within 32-bit limits).
Right shift (>>)
Shifts bits right while preserving the sign bit (arithmetic shift).
Unsigned right shift (>>>)
Shifts bits right and inserts zeros on the left, treating the value as unsigned.
Input formats and examples
You can enter values in these forms:
- Decimal:
27,-14 - Binary:
0b11011 - Hexadecimal:
0x1B - Octal:
0o33
Example: 0xF0 & 0b10101111 lets you mix formats; both values are converted before calculation.
Important JavaScript behavior (32-bit integers)
In JavaScript, bitwise operations are performed on 32-bit signed integers. That means values are internally converted, and large numbers may wrap according to two's complement rules. If you are working with networking headers, binary protocols, or flags, this behavior is expected and often desired.
Practical use cases
- Flags and permissions: store multiple true/false settings in one integer.
- Color channels: extract or combine RGB(A) components.
- Data packing: compress multiple fields into a single number.
- Performance tricks: fast checks and transformations in low-level code paths.
- Protocol parsing: read specific bits from binary packet fields.
Common mistakes to avoid
- Confusing logical operators (
&&,||) with bitwise operators (&,|). - Forgetting that shifts use only 0–31 positions in JavaScript.
- Assuming results stay larger than 32 bits after bitwise operations.
- Ignoring signed vs unsigned interpretation when reading decimal output.
Final thoughts
Bitwise operations can feel abstract at first, but a calculator makes them concrete. Try different values, inspect the binary output, and you will quickly build intuition. Once that clicks, bitwise logic becomes one of the most practical tools in your programming toolkit.