Skip to content
EN
  • Español
  • English
Advertisement

Logic gates and truth tables: AND, OR, NOT, NAND, NOR, XOR

Work out the output of an AND, OR, NOT, NAND, NOR, XOR or XNOR gate with up to 4 inputs, with its IEC 60617-12 symbol and the full truth table.

Fill in every field but one and the missing one is calculated. You can type in any of them.

—
—
Type the output you want and leave an input empty: you get the value that gives it.
—
Row of the truth table—
Rows with output 1—
Rows in the table (2ⁿ)—

Use this calculator for reference only, as we cannot guarantee that the results are free of errors.

Disclaimer

https://dyaii.es/en/logic-gate-truth-table-calculator/

Advertisement

A logic gate takes one or more inputs that can only be 0 or 1 (off or on, false or true) and gives an output that is also 0 or 1. Digital circuits are built from them, from a microprocessor to a PLC program: two contacts in series are an AND, two in parallel are an OR and a normally closed contact is a NOT.

The seven gates

GateIEC symbolExpressionGives 1 when…
AND&Y = A · Ball inputs are 1
OR≥1Y = A + Bat least one input is 1
NOT1 with circleY = Āthe input is 0
NAND& with circleY = (A · B)‾some input is 0
NOR≥1 with circleY = (A + B)‾all inputs are 0
XOR=1Y = A ⊕ Bthere is an odd number of ones
XNOR=1 with circleY = (A ⊕ B)‾there is an even number of ones

The symbols are the rectangular ones of IEC 60617-12, used in European electrical drawings: a rectangle with the sign inside and a small circle on the output when it is inverted. North American drawings (IEEE 91) use curved shapes, but the gates do the same.

The truth table

It lists the output for every combination of inputs: 2ⁿ rows for n inputs (4 for 2, 8 for 3, 16 for 4). Rows are ordered by counting in binary, with A as the most significant bit, so row 4 of a 2-input gate is A = 1, B = 1. A 3-input AND only gives 1 on the last row; a 3-input OR, on all but the first.

Advertisement

XOR with more than two inputs

With two inputs, XOR gives 1 when they differ. With more, the standard defines it as "an odd number of inputs at 1" (what you get by chaining 2-input XORs, and the parity bit). If you need "exactly one input at 1", it has to be built from other gates.

Universal gates

NAND alone can build any circuit: NOT A = A NAND A; A AND B = NOT (A NAND B); A OR B = (NOT A) NAND (NOT B). NOR is universal too. De Morgan's laws sum it up: (A · B)‾ = Ā + B̄ and (A + B)‾ = Ā · B̄.

How to use the calculator

Choose the gate and the number of inputs and type each input (0 or 1), or click them in the drawing: you get the output and the row of the table you are on. The other way round, type the output you want and leave one or more inputs empty: the calculator fills in the first combination in the table that gives it, or warns if there is none.

Advertisement

Frequently asked questions

What does each logic gate do?

AND gives 1 only if all inputs are 1; OR, if at least one is 1; NOT inverts its single input. NAND and NOR are inverted AND and OR. XOR gives 1 if there is an odd number of ones (with two inputs, if they differ) and XNOR, if it is even.

What do the symbols &, ≥1 and =1 mean?

They are the rectangular symbols of IEC 60617-12 (used in European drawings): & is AND, ≥1 is OR (at least one input at 1), =1 is XOR (exactly one) and 1 is the buffer; the circle on the output means it is inverted (NOT, NAND, NOR, XNOR).

How many rows does a truth table have?

2ⁿ, n being the number of inputs: 4 rows with 2 inputs, 8 with 3 and 16 with 4. A 3-input AND gives 1 on a single row out of 8; a 3-input OR, on 7 out of 8.

Why is NAND called a universal gate?

Because any other gate can be built from NANDs: NOT A = A NAND A; A AND B = NOT (A NAND B); A OR B = (NOT A) NAND (NOT B). The same goes for NOR. That is why many integrated circuits only contain NANDs.

Related calculators

Share

WhatsApp X LinkedIn Telegram Email
Advertisement

Install Diseño y automatización de instalaciones industriales on your phone

All the calculators one tap away, full screen, like an app. It takes no space and is always up to date.