Interactive Bitwise Calculator
Enter values as decimal (42), binary (0b101010), hex (0x2A), or octal (0o52).
What is a bitwise operation calculator?
A bitwise operation calculator helps you manipulate integers at the binary level. Instead of working with whole decimal values alone, bitwise operations compare and modify individual bits (0s and 1s). This is useful in programming, systems design, embedded development, networking, and performance-sensitive logic.
If you have ever worked with flags, masks, permissions, packed data, checksums, or low-level optimization, bitwise operations are a core skill. This calculator is designed to make those operations quick to test and easy to understand.
How to use this calculator
1) Enter your numbers
You can use multiple number formats:
- Decimal:
25 - Binary:
0b11001 - Hex:
0x19 - Octal:
0o31
2) Pick an operation
- AND (&) – keeps bits where both sides are 1.
- OR (|) – keeps bits where either side is 1.
- XOR (^) – keeps bits where the sides differ.
- NOT (~) – flips all bits of operand A.
- <<, >>, >>> – shifts bits left or right.
3) Read results in multiple representations
The calculator shows signed decimal, unsigned decimal, hexadecimal, and full 32-bit binary. Seeing all formats together helps avoid errors when debugging bit masks and two’s-complement values.
Bitwise operations explained
AND (&): ideal for masking
AND is commonly used to test whether a flag bit is set. If you store permissions in one integer, a mask can isolate a single permission quickly.
OR (|): ideal for setting flags
OR can turn specific bits on without changing other bits. This is useful when enabling options in a packed settings value.
XOR (^): ideal for toggling bits
XOR flips bits where the mask is 1. Apply the same XOR mask twice and you get your original number back.
NOT (~): invert all bits
NOT flips every bit in a 32-bit integer. In JavaScript and many languages, this works with signed 32-bit integers, so negative results are expected and normal.
Shift operators: fast powers of two and bit movement
A << B: shifts left; roughly multiplies by 2B (within 32-bit limits).A >> B: arithmetic right shift; preserves sign bit.A >>> B: logical right shift; fills with 0s and returns an unsigned result.
Important note: JavaScript uses 32-bit signed behavior for bitwise ops
This calculator follows JavaScript rules, where bitwise operations convert values to 32-bit signed integers. That means:
- Large numbers are truncated to 32 bits.
- Negative numbers are represented using two’s complement.
- Shift counts effectively use the lower 5 bits (0–31).
When results look surprising, check the 32-bit binary line. It usually makes the behavior immediately clear.
Real-world use cases
- Permission systems: read/write/execute flags in one integer.
- Graphics: pack RGBA channels into a 32-bit value.
- Networking/protocols: parse control bits and headers.
- Embedded systems: control hardware registers efficiently.
- Performance tuning: fast checks, masks, and bit packing.
Common mistakes to avoid
- Mixing decimal and binary mentally without verifying the bit pattern.
- Forgetting that
>>>differs from>>on negative values. - Assuming shifts beyond 31 bits work as expected without masking.
- Ignoring signed vs unsigned interpretations of the same 32-bit pattern.
Use this bitwise operation calculator whenever you need reliable, quick binary math and clear format conversions. It is especially helpful for debugging and learning how low-level logic behaves in real code.