radixflip

Logic Gates

Pick a gate, toggle its inputs, and watch the output. Switch on Detail view to see a compound gate broken into basic gates.

Try a Gate

Bitwise calculator →  ·  1's and 2's complement →

How to use a logic gate

  1. Pick a gate. AND, OR, NOT, XOR, NAND, NOR or XNOR.
  2. Set the inputs. Click the A and B buttons to toggle each input between 0 and 1. NOT has one input.
  3. Read the output. The input values travel into the gate, then one chip carrying the result travels out to the lamp. The lamp lights up when the output is 1.
  4. Check the truth table. It lists every input combination; the row matching the current inputs is highlighted.
  5. See inside a compound gate. Switch on Detail view to see NAND, NOR, XOR or XNOR broken into basic gates, with each value traveling between stages.

What each gate does

GateRuleExpression
AND1 only when A and B are both 1Y = A · B
OR1 when A or B (or both) is 1Y = A + B
NOTFlips its input: 0 becomes 1, 1 becomes 0Y = Ā
XOR1 only when A and B differY = A ⊕ B
NAND0 only when A and B are both 1Y = NOT (A · B)
NOR1 only when A and B are both 0Y = NOT (A + B)
XNOR1 only when A and B are equalY = NOT (A ⊕ B)

Frequently asked questions

What is a logic gate?

A logic gate is a small circuit that takes one or two bits (0 or 1) as input and produces one bit as output, following a fixed rule. AND outputs 1 only when both inputs are 1. OR outputs 1 when at least one input is 1. NOT flips its single input. Pick a gate above and toggle the inputs to watch it work.

What is the difference between AND, OR and XOR?

AND outputs 1 only when A and B are both 1. OR outputs 1 when A or B (or both) is 1. XOR outputs 1 only when A and B differ — one 1 and one 0. The truth table above shows all four input combinations for each gate.

What are NAND and NOR gates?

NAND is AND followed by NOT: it outputs 0 only when both inputs are 1. NOR is OR followed by NOT: it outputs 1 only when both inputs are 0. They are called universal gates because any other gate can be built from NAND gates alone, or from NOR gates alone.

What is the difference between XOR and XNOR?

XOR outputs 1 when its inputs differ. XNOR is XOR followed by NOT, so it outputs 1 when its inputs are equal — both 0 or both 1. XNOR is sometimes called the equivalence gate because it checks whether two bits match.

Where are logic gates used?

Everywhere in digital electronics. Processors are built from millions of gates: adders use XOR and AND, memory uses NAND and NOR latches, and control logic combines gates to decide what happens each clock cycle. Learning gates is the first step to understanding how a computer adds, stores and decides.

How is XOR built from basic gates?

XOR is (A AND NOT B) OR (NOT A AND B): two NOT gates flip the inputs, two AND gates combine each input with the other flipped input, and an OR gate joins the results. NAND is an AND gate followed by NOT, NOR is an OR gate followed by NOT, and XNOR is (A AND B) OR (NOT A AND NOT B). Switch on Detail view above to watch the values travel through each stage.

Bitwise calculator →  ·  Binary calculator →