Base-N · Concept

Bitwise AND, OR & XOR Explained

The five bit operators with truth tables, worked binary examples, and the masking tricks programmers actually use.

fx-991ES Web TeamUpdated 23 June 20267 min read

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.

On this page

  1. Truth tables
  2. Worked examples
  3. Masking: set, clear, toggle, test
  4. On the calculator
  5. FAQ

Truth tables

aba AND ba OR ba XOR b
00000
01011
10011
11110

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

Toggle example

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 →