Logical XOR

From Wikiversity

Jump to: navigation, search
Nuvola apps edu miscellaneous.svg Resource type: this resource is a lesson.

Welcome! This is a lesson in the Introductory Discrete Mathematics for Computer Science course here at Wikiversity.

Previous lesson: Logical OR

Contents

[edit] Introducing the Exclusive OR!

\oplus : This is the XOR operator. It is also called the exclusive OR, to distinguish it from the inclusive OR of the previous lesson. Like the inclusive OR, it is a diadic operator; unlike any other operator, it is true when one and only one input is true.

Let p represent the statement: It is raining.
Let q represent the statement: I am hungry.
p \oplus q represents the exclusive disjunction of statements p and q: It is raining OR I am hungry, But not both.

[edit] Truth Table

Its truth table is unique. Here it is!

p \,\! q \,\! p \oplus q
T T F
T F T
F T T
F F F

[edit] Why XOR is Special

XOR is used for adding binary numbers, and is the fundamental arithmetic operation used by computers.

[edit] Next Lesson

Your next lesson is called Conditional Operator.