Bitwise operators work on the individual bits of a number rather than its value as a whole. They're the foundation of flags, masks and low-level optimisation — and a bitwise calculator lets you watch them work bit by bit.
Truth tables
| a | b | a AND b | a OR b | a XOR b |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
NOT flips every bit; XNOR is the negation of XOR (1 when the bits match).
Worked examples
Using 12 (1100) and 10 (1010):
1100 (12) 1100 (12) 1100 (12)
AND 1010 (10) OR 1010 (10) XOR 1010 (10)
---- ---- ----
1000 = 8 1110 = 14 0110 = 6
12 AND 10 = 8, 12 OR 10 = 14, 12 XOR 10 = 6.
Masking: set, clear, toggle, test
- Set bits →
ORwith a mask that has 1s where you want 1s. - Clear bits →
ANDwith a mask that has 0s where you want 0s. - Toggle bits →
XORwith a mask that has 1s where you want to flip. - Test a bit →
ANDwith a single-bit mask; a non-zero result means the bit was set.
Flip the low bit of 12 (1100): 12 XOR 1 = 1101 = 13. XOR again returns to 12 — the toggle is reversible.
On the calculator
Switch to BASE-N mode and use the logical-operations menu for AND, OR, XOR, XNOR and NOT. Viewing in binary shows each operation bit by bit. To build the operands first, see the decimal to binary conversion guide, and for the whole mode the binary, octal & hex calculator pillar guide.
Frequently asked questions
What do AND, OR and XOR do?
AND: 1 only if both bits are 1. OR: 1 if either is 1. XOR: 1 if the bits differ.
What is bit masking?
Applying a pattern with a bit operator — AND clears/tests, OR sets, XOR toggles.
How do I run these on the calculator?
In BASE-N mode, use the logical-operations menu and view in binary.
See the bits flip
Try 12 XOR 10 in BASE-N mode and switch to binary to watch it happen.
Open the bitwise calculator →