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.