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 1OR: 1 when either bit is 1XOR: 1 when the bits differa << n = a × 2ⁿ, a >> n = a ÷ 2ⁿ
Inputs explained
| Input | Unit | Required | Notes |
|---|---|---|---|
| First operand | text | Yes | — |
| Second operand | text | Yes | Ignored for NOT. For shifts this is the shift amount. |
| Operands are in | one of 4 options | Yes | — |
| Operation | one of 7 options | Yes | — |
| Bit width | one of 4 options | Yes | — |
How to use it
- Choose Operands are in and Operation.
- Enter First operand and Second operand.
- 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.