Skip to content
Popular Calculators
Browse Math calculators

Boolean Logic Calculator

Find the output of AND, OR, NOT, NAND, NOR, XOR and XNOR logic gates for your inputs, with the gate's truth table, expression and NAND-only equivalent.

Number of inputs (optional)
Input A (optional)
Input B (optional)

Result

OutputXOR(1, 0) = 1
ExpressionQ = A ⊕ B
Ruleoutput is 1 when an odd number of inputs are 1
NAND onlywith NAND gates only: four NANDs: N = A NAND B, then (A NAND N) NAND (B NAND N)
Chipcommon TTL/CMOS chip: 7486 (quad 2-input XOR)
Worth knowing1 means high or true, 0 means low or false; NAND and NOR are universal, so any circuit can be built from either alone

How this was calculated

  1. A BQ
  2. 0 00
  3. 0 11
  4. 1 01
  5. 1 10

About the Boolean Logic Calculator

Logic gates are the building blocks of every digital device, from a calculator to a data centre. Each gate takes one or more binary inputs, each 0 or 1, and produces a binary output by a simple rule. Combining a few gate types builds adders, memory cells, multiplexers and processors. Understanding exactly what each gate does is the first step in digital electronics.

This Boolean logic calculator gives the output of an AND, OR, NOT, NAND, NOR, XOR or XNOR gate for the inputs you set, with two or three inputs. It shows the gate's Boolean expression, its full truth table, the rule in plain words, how to build it from NAND gates alone and which common 7400-series chip contains it.

How to Use the Boolean Logic Calculator

Choose the gate.

Choose two or three inputs. A NOT gate always has one input, A.

Set each input to 0 or 1.

The Formulas

  AND    Q = A·B          1 only if all inputs are 1
  OR     Q = A + B        1 if any input is 1
  NOT    Q = A'           the opposite of the input
  NAND   Q = (A·B)'       0 only if all inputs are 1
  NOR    Q = (A + B)'     1 only if all inputs are 0
  XOR    Q = A ⊕ B        1 if an odd number of inputs are 1
  XNOR   Q = (A ⊕ B)'     1 if an even number of inputs are 1

Step-by-Step Example

An XOR gate with A = 1 and B = 0.

  rule: output is 1 when an odd number of inputs are 1
  inputs: one 1 → odd → Q = 1
  truth table:  0 0 → 0    0 1 → 1    1 0 → 1    1 1 → 0
  NAND-only: N = A NAND B, then (A NAND N) NAND (B NAND N)

A three-input NAND with A = B = C = 1. All inputs are 1, so the AND is 1 and the NAND output is 0. On every other row the output is 1.

The Gates in Detail

AND and OR are the most intuitive: AND is like switches in series, where current flows only if every switch is closed; OR is like switches in parallel, where any closed switch lets current through. NOT, or an inverter, flips its input.

NAND and NOR add an inverter to AND and OR. They are the cheapest gates to build in CMOS and TTL technology, which is why they are so common in real chips.

XOR, exclusive OR, is 1 when its two inputs differ. It is the sum bit of a half adder, the core of parity generators and checkers, and a controllable inverter: XOR with 1 flips a bit, XOR with 0 leaves it alone. XNOR is 1 when its inputs match and is used as an equality comparator.

Universal Gates

NAND and NOR are called universal because any logic function can be built from either one alone. With NAND gates:

  NOT A    = A NAND A
  A AND B  = (A NAND B) NAND (A NAND B)
  A OR B   = (A NAND A) NAND (B NAND B)
  A XOR B  = (A NAND N) NAND (B NAND N),  where N = A NAND B

Manufacturers have long built whole circuits from a single gate type to simplify production, and the four-NAND XOR is a classic exercise that shows how far one gate can go.

Gates With More Inputs

AND, OR, NAND and NOR extend naturally to three or more inputs: AND needs every input high, OR needs at least one. Chips such as the 7411 triple 3-input AND, the 7410 triple 3-input NAND and the 7427 triple 3-input NOR provide them directly. Multi-input XOR is usually built from a chain of 2-input XOR gates, and its output is the parity of the inputs: 1 when an odd number are 1.

Logic Levels in Real Circuits

In hardware, 0 and 1 are voltage ranges rather than exact values. Classic 5 V TTL treats inputs below about 0.8 V as low and above about 2 V as high. CMOS families running at 3.3 V or 5 V have their own thresholds. Inputs should never be left floating; tie unused inputs to a defined level, or the gate may behave unpredictably.

Combining Gates Into Circuits

Gates connect output to input to build larger functions. A half adder, which adds two bits, uses an XOR for the sum and an AND for the carry: 1 + 1 gives sum 0, carry 1. Two half adders and an OR gate make a full adder, and chaining full adders adds whole binary numbers. A 2-to-1 multiplexer, which selects one of two signals, is built from two AND gates, an OR gate and an inverter. A set-reset latch, the simplest memory cell, is two NOR or two NAND gates cross-coupled so each output feeds the other's input.

Working out the output of such a circuit means applying the gate rules stage by stage, which is exactly what this calculator does for one gate at a time. For a whole expression, the Boolean expression calculator builds the full truth table.

Timing and Propagation Delay

Real gates are not instant. Each takes a few nanoseconds to respond, its propagation delay, and signals passing through several gates add up those delays. Briefly unequal paths can cause short false pulses, called glitches or hazards, which designers remove with extra terms or by sampling outputs with a clock. A truth table describes the settled output, after the inputs have been steady for long enough.

Understanding Your Result

The headline gives the gate's output for your inputs.

The expression line gives the Boolean expression, and the rule line states it in words.

The NAND only line explains how to build the gate from NAND gates.

The chip line names a common 7400-series part.

The steps list the full truth table for the gate.

When Should You Use This Calculator?

Use it to learn or revise what each logic gate does.

Use it to check truth tables for digital electronics homework.

Use it when choosing gates or chips for a simple circuit.

Common Mistakes

Confusing OR with XOR. OR gives 1 for inputs 1 and 1; XOR gives 0.

Forgetting NAND and NOR invert. A NAND is 1 for most inputs.

Leaving inputs floating. Tie unused inputs high or low.

Assuming 3-input XOR is "exactly one". It is 1 for one or three 1s.

Frequently Asked Questions

What does each logic gate do?

AND outputs 1 only when all inputs are 1, OR when any input is 1, and NOT inverts its input. NAND and NOR are AND and OR followed by NOT. XOR outputs 1 when the inputs differ, XNOR when they match.

What is the output of an XOR gate with inputs 1 and 0?

1, because the inputs differ. XOR gives 0 for 0 and 0 or for 1 and 1. With more inputs, XOR outputs 1 whenever an odd number of inputs are 1, which is why it is used for parity checks.

Why are NAND and NOR called universal gates?

Any logic function can be built from NAND gates alone, or from NOR gates alone. A NOT is a NAND with its inputs tied together, and AND and OR follow by adding inverters. Chips often use one gate type for cost.

How do you build XOR from NAND gates?

Use four NANDs. The first computes N = A NAND B, two more compute A NAND N and B NAND N, and the fourth NANDs those two results together. Adding a fifth NAND as an inverter gives XNOR.

What do 0 and 1 mean in a circuit?

0 is logic low, false or off, usually near 0 volts; 1 is logic high, true or on, near the supply voltage such as 5 V for classic TTL or 3.3 V for many modern circuits.

Which chips contain these gates?

Classic 7400-series parts include the 7408 AND, 7432 OR, 7404 inverter, 7400 NAND, 7402 NOR and 7486 XOR. Modern HC and HCT versions have the same pinouts and work at lower power.

Formula and article last checked September 28, 2026. How we test these calculators.