A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

XOR and XNOR Gates

College Depth 83 in the knowledge graph ☐ I know this ☆ Set as goal
219topics build on this
330prerequisites beneath it
See this on the map →
Logic Gates FundamentalsUniversal Gates: NOR and NAND→→Half Adder Circuit Design
gates xor comparison

Core Idea

XOR outputs true when inputs differ; XNOR outputs true when inputs are equal. XOR is essential for comparators and parity checking, while XNOR implements logical equivalence.

How It's Best Learned

Write the XOR and XNOR truth tables side by side, then extend XOR to three inputs and notice the output is 1 when an odd number of inputs are 1. Next XOR 1011 0010 with 0110 1100 to get 1101 1110, and XOR that result with 0110 1100 again to recover the original byte. Finally, build XOR from four NAND gates and check all four input rows.

Common Misconceptions

Explainer

You already know the basic logic gates — AND, OR, NOT, NAND, NOR — and how they combine inputs to produce outputs according to truth tables. XOR (exclusive OR) and XNOR (exclusive NOR) extend this family with a behavior that none of the basic gates provide: detecting whether two inputs are the same or different.

The XOR gate outputs 1 when its inputs *differ* — specifically, when exactly one input is 1. For two inputs A and B: XOR outputs 1 when A=0,B=1 or A=1,B=0, and outputs 0 when both inputs match (both 0 or both 1). In Boolean algebra, this is written as A ⊕ B, and it can be decomposed into basic gates as A·B' + A'·B. Think of XOR as answering the question "are these two bits different?" This makes it indispensable for comparison circuits: to check whether two multi-bit numbers are equal, you XOR corresponding bits — if any XOR output is 1, the numbers differ at that position.

The XNOR gate is simply the complement of XOR: it outputs 1 when the inputs are the *same*. XNOR implements logical equivalence — the operation that tests whether A and B have the same truth value. In Boolean algebra, A ⊙ B = A·B + A'·B'. You can think of XNOR as answering "are these two bits equal?" Every XOR output inverted is an XNOR output, so the two gates always appear as a complementary pair.

Beyond comparison, XOR has several properties that make it uniquely useful in digital design. It is self-inverting: A ⊕ A = 0 (any value XORed with itself is 0) and A ⊕ 0 = A (XORing with 0 preserves the value). This makes XOR the core of parity checking — XOR all the bits together, and the result tells you whether the total number of 1s is odd (result=1) or even (result=0). Error detection codes like parity bits rely on this directly. XOR also appears in binary addition: the sum bit of a half-adder is exactly A ⊕ B, because 0+0=0, 0+1=1, 1+0=1, and 1+1=0 (with a carry). This connection between XOR and addition is not a coincidence — addition modulo 2 is precisely the XOR operation. You will see XOR appear repeatedly as you move into more complex combinational circuits, from adders to checksums to cryptographic building blocks.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Universal Gates: NOR and NAND → XOR and XNOR Gates

Longest path: 84 steps · 330 total prerequisite topics

Prerequisites (2)

Leads To (1)