Logic gates are the building blocks of every digital circuit, from a calculator chip to a processor with billions of transistors. Each gate takes one or more binary inputs — 1 (high, true) or 0 (low, false) — and produces a single binary output according to a fixed rule.
This logic gate calculator works in two modes:
- Single gate. Pick AND, OR, NOT, NAND, NOR, XOR or XNOR, choose 2, 3 or 4 inputs, set each input to 0 or 1 and read the output. You also get the gate’s Boolean expression, its rule in plain words, its IEEE 91 rectangular symbol qualifier and the complete truth table, with the row matching your inputs marked.
- Boolean expression. Type any expression in the variables A, B, C and D — such as
(A AND B) OR NOT CorA·B + C′— and the calculator parses it, evaluates it for your inputs and generates its truth table, its minterms and its canonical sum of products.
It is designed for students in digital electronics, computer science and discrete mathematics who want to check a truth table, and for hobbyists planning a small circuit.
How to use this calculator
- Choose Single gate or Boolean expression.
- For a gate, select its type and the number of inputs (NOT always has one). For an expression, type it using A–D, 0 and 1, the words AND, OR, NOT, XOR, NAND, NOR, XNOR or the symbols · & + | ¬ ! ⊕ ^ and a trailing ′ for NOT. Writing
ABmeans A AND B. - Set each input to 0 or 1 with the buttons.
- Read the output Y, then check the truth table: every input combination is listed in binary counting order, and ◀ marks the current one. The steps show the substitution.
The formula
With for AND, for OR, for XOR and for NOT:
With more inputs, AND and OR extend naturally (), and XOR becomes the odd-parity function: when an odd number of inputs is 1. A table with inputs has rows. De Morgan’s laws link the gates: and .
Worked example
Take the expression (A AND B) OR NOT C, written algebraically as (the calculator shows A·B + ¬C).
With , , : and , so . Switch B to 1 and , so .
The expression uses three variables, so its truth table has rows. The output is 1 in 5 of them: the minterms are — every row where C = 0, plus the row A = B = C = 1.
Truth tables of the two-input gates
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Read each column as a rule: AND needs both inputs high, OR at least one, XOR exactly one; NAND, NOR and XNOR invert AND, OR and XOR.
Universal gates, parity and IEEE symbols
NAND and NOR are universal: any Boolean function can be built from NAND gates alone (or NOR gates alone). For example, a NAND with both inputs tied together is a NOT gate, and two NANDs in series make an AND. That is why NAND-only logic is common in integrated circuits.
Multi-input XOR gates in most textbooks and chip families compute odd parity, which is the result of chaining two-input XORs. IEEE Std 91 distinguishes this odd-parity element (qualifier “2k+1”) from the strict “exactly one input” exclusive-OR (qualifier “=1”); for two inputs they coincide.
In the IEEE 91 rectangular symbols, a gate is a box with a qualifier inside: “&” for AND, “≥1” for OR, “=1” for XOR and “1” for a buffer; a small circle (or a triangle in the polarity convention) at the output marks negation, turning AND into NAND and OR into NOR. The familiar curved distinctive shapes are the alternative form allowed by the same standard. To work with the binary numbers these gates process, see the binary calculator and the bit shift calculator.
Frequently asked questions
What is the difference between XOR and OR?
OR outputs 1 when at least one input is 1, including when both are. XOR (exclusive OR) outputs 1 only when the inputs differ, so 1 XOR 1 = 0 while 1 OR 1 = 1.
How many rows does a truth table have?
Two to the power of the number of inputs: 4 rows for 2 inputs, 8 for 3 and 16 for 4. The calculator lists them in binary counting order, with A as the most significant bit.
Why are NAND and NOR called universal gates?
Because NOT, AND and OR — and therefore every Boolean function — can be built using only NAND gates, or only NOR gates. For instance NOT A = A NAND A.
What does a 3-input XOR gate output?
It outputs 1 when an odd number of inputs is 1: one or all three. This is the parity function used in error-detecting parity bits; XNOR gives the even-parity complement.
What are minterms?
A minterm is a row of the truth table where the output is 1, numbered by reading the inputs as a binary number. Summing (OR-ing) the matching AND terms gives the canonical sum of products, the starting point for simplifying a circuit with Boolean algebra or a Karnaugh map.
Sources
- IEEE Std 91/91a — Graphic Symbols for Logic Functions (IEEE Standards Association)
- M. M. Mano & M. D. Ciletti, Digital Design, 6th ed., Pearson — Ch. 2 (Boolean algebra and logic gates)
Last updated: