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

XOR and XNOR Gates

College Depth 74 in the knowledge graph I know this Set as goal
209topics build on this
323prerequisites beneath it
See this on the map →
Logic Gates FundamentalsUniversal Gates: NOR and NANDHalf 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.

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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsXOR and XNOR Gates

Longest path: 75 steps · 323 total prerequisite topics

Prerequisites (2)

Leads To (1)