Josh Havins Personal Web Page

The enemy of my enemy is an XNOR

I'm sure you've heard the phrase, the enemy of my enemy is my friend. Did you know that this statement can be represented by a logic table? To explain, let's start with an OR logic table.


Keep this in mind: True is represented by the binary digit 1. False is represented by the binary digit 0. There are two inputs, A and B.


In the OR logic table, if either input, A or B, is a 1, then the result is 1 (or true).


OR Table:

A B Result
0 (false) 0 (false) 0 (false)
0 (false) 1 (true) 1 (true)
1 (true) 0 (false) 1 (true)
1 (true) 1 (true) 1 (true)

Now, I'll explain the NOR logic table, or Negated OR. This is exactly the same as the OR logic table, but the result is flipped to the opposite value. 0 becomes 1, and 1 becomes 0.


NOR Table:

A B Result
0 (false) 0 (false) 1 (true)
0 (false) 1 (true) 0 (false)
1 (true) 0 (false) 0 (false)
1 (true) 1 (true) 0 (false)

Next up, XOR, or Exclusive OR. If either input value, A or B, is a 1 (true), then the result is true. However, if BOTH A and B are 1 (true), then the result is 0 (false). That's what is meant by Exclusive. Either or, but not both.

XOR Table:

A B Result
0 (false) 0 (false) 0 (false)
0 (false) 1 (true) 1 (true)
1 (true) 0 (false) 1 (true)
1 (true) 1 (true) 0 (false)

Now for the moment you've been waiting for. Exclusive Negated OR, or XNOR. Once again, all we do here is reverse the results of the XOR. How does this relate to the Enemy of my Enemy is my Friend? Well instead of seeing 1 and 0 as true and false, see 1 and friend and 0 as enemy.

XNOR Table:

A B Result
0 (enemy) 0 (enemy) 1 (friend)
0 (enemy) 1 (friend) 0 (enemy)
1 (friend) 0 (enemy) 0 (enemy)
1 (friend) 1 (friend) 1 (friend)

Make sense?