Bitwise operators — AND, OR, XOR, NOT, and the two shifts — work directly on the binary representation of a number, one bit at a time, instead of on its decimal value. They show up constantly in programming: bitmasks, flags, permissions, hashing, and low-level performance tricks all lean on them. This calculator lets you enter two integers in decimal, binary, or hex, apply any of the six operations, and see exactly which bits changed.

How each operation works

AND, OR, and XOR each compare A and B one bit position at a time and combine them according to a simple rule: AND keeps a 1 only where both inputs are 1, OR keeps a 1 where either input is 1, and XOR keeps a 1 only where the inputs disagree. NOT is different — it takes a single input and flips every bit, which at a fixed bit width is the same as computing −A−1.

The two shift operations move bits sideways instead of combining two numbers. A left shift by n multiplies the value by 2ⁿ, shifting every bit toward the high end and filling the low end with zeros. A right (logical) shift by n divides by 2ⁿ and rounds down, shifting every bit toward the low end and discarding whatever falls off the right edge.

Inputs and what they mean

Pick the base your numbers are written in — decimal, binary, or hex — and the bit width (8, 16, or 32 bits) that the calculation is performed at. The bit width matters because it determines how NOT and negative numbers behave: everything is computed using two's complement at that width, so the same operation on the same numbers can give a different bit pattern at 8-bit versus 16-bit width.

For AND, OR, and XOR, both Value A and Value B are full operands. For a shift, Value B is reinterpreted as the shift amount in bits (always read as a plain decimal number, regardless of the selected base) rather than as a second operand. NOT only uses Value A.

Limits and edge cases

Negative decimal input is supported and stored via two's complement at the chosen bit width — for example, −1 at 8-bit width is the all-ones pattern 11111111. Shifting by an amount at or beyond the configured bit width simply clears every bit, since there's nothing left to shift. This calculator focuses on integer bitwise operations; for converting a number between number systems without applying an operation, use the Number Base Calculator instead.