Bitwise Calculator
Calculate AND, OR, XOR, NOT and shifts with binary and hexadecimal output.
Overview
The Bitwise Calculator performs AND, OR, XOR, NOT, left shift and right shift on integers and displays the result in decimal, hexadecimal and binary. Paste two values, pick an operation and you get the bit-by-bit breakdown alongside the numeric answer.
It is built for embedded developers reading register documentation, network engineers slicing subnet masks, students learning binary representation and anyone debugging permission bitfields or feature flags. Seeing the binary columns line up makes a confusing one-liner like x & ~0xff instantly obvious.
How it works
Each operand is parsed as decimal, hexadecimal (with 0x prefix), octal (0) or binary (0b). The operations work bit-by-bit on the two's-complement representation: AND outputs 1 where both inputs are 1, OR outputs 1 where at least one is, XOR outputs 1 where exactly one is, NOT flips every bit.
Shifts are arithmetic. A left shift by k multiplies by 2^k, a right shift by k divides by 2^k (rounding toward zero for signed values, or simply discarding bits on unsigned). The result is shown in three bases so you can pick whichever fits the context.
Examples
0b1100 AND 0b1010 → 0b1000 (decimal 8)
0xFF XOR 0x0F → 0xF0 (decimal 240)
5 << 3 → 40 (0b101000)
NOT 0 → -1 (0xFFFFFFFF in 32-bit two's complement)
FAQ
What's the difference between logical and bitwise AND?
Logical AND returns true/false based on whether both operands are truthy. Bitwise AND compares each pair of bits and returns a number.
Why does NOT zero give -1?
In two's complement, all-bits-one represents -1 for signed integers (or 0xFFFFFFFF as unsigned 32-bit).
Does shift treat negative numbers correctly?
Right shift preserves the sign bit (arithmetic shift), so -8 >> 1 is -4, not a huge positive number. Left shift simply multiplies by two.
Can I enter hex without the 0x?
The tool defaults to decimal unless a prefix is present. Use 0x for hex and 0b for binary to remove ambiguity.
What's the width of the result?
The calculator works with 64-bit signed integers internally. Most practical bitfield work fits easily inside that range.