Bitwise Calculator

Apply AND, OR, XOR, NOT and shift operations at any bit width.

What the Bitwise Calculator does

Bitwise operations work on individual bits rather than the number as a whole. They underpin flags, masks, permissions and hashing, and shifting is the cheapest way a processor can multiply or divide by a power of two.

Formula

  • AND: 1 only when both bits are 1
  • OR: 1 when either bit is 1
  • XOR: 1 when the bits differ
  • a << n = a × 2ⁿ, a >> n = a ÷ 2ⁿ

Inputs explained

InputUnitRequiredNotes
First operandtextYes
Second operandtextYesIgnored for NOT. For shifts this is the shift amount.
Operands are inone of 4 optionsYes
Operationone of 7 optionsYes
Bit widthone of 4 optionsYes

How to use it

  1. Choose Operands are in and Operation.
  2. Enter First operand and Second operand.
  3. Select Calculate.

Worked example

12 AND 10 at 32-bit width.

A
12
B
10
Operation
AND

12 is 1100 and 10 is 1010. Only the 8s bit is set in both, so the result is 1000 — decimal 8.

Frequently asked questions

What is the difference between >> and >>>?

Arithmetic shift (>>) copies the sign bit, so −8 >> 1 stays −4. Logical shift (>>>) fills with zeros, turning a negative into a large positive.

Why use XOR for toggling?

XOR with 1 flips a bit and XOR with 0 leaves it alone, so a mask toggles exactly the bits you choose. Applying the same XOR twice returns the original value.

Related calculators