ôô

How Do Computers Add? Part 2

Have you ever wondered how computers and calculators—both of which are nothing more than mindless boxes of plastic, wires, and other strange parts—manage to add numbers? And so quickly! Math Dude has the second part of the story.

By
Jason Marshall, PhD
4-minute read
Episode #146

 

How to Build an XOR Gate

Before we figure out how to build the rest of our adding machine, let’s take a quick look at how you can actually build an XOR gate. There are lots of ways to do it, but one way is to use one OR, two AND, and one NOT gate. Both input bits are fed into the OR gate on one branch (which we’ll call the top branch) and an AND gate on the other. The output of the AND gate on the bottom branch passes through a NOT gate, and is then combined with the output of the top branch’s OR gate in the final AND gate…like this:

If you plug the possible values of the two input bits in and trace out the results as you go through each AND, OR, and NOT gate, you’ll find that the output bits are exactly what you’d expect from an XOR gate. For example, if the first input bit is 1 and the second is 0, the OR in the top branch outputs 1 (since 1 OR 0 = 1) while the AND on the bottom branch outputs 0 (since 1 AND 0 = 0). The 0 from the AND on the bottom then passes through a NOT gate, which means that it outputs 1. The 1s from the top and bottom branches then enter the last AND gate which outputs 1…as expected. On the other hand, if both input bits are 1, the OR in the top branch outputs 1, while the AND followed by the NOT gate in the bottom branch outputs 0. Which means that the final AND gate outputs 0 (since 1 AND 0 = 0).

As you can check, this arrangement of gates works for each of the other two input bit combinations as well. Pretty cool, right?

Pages

About the Author

Jason Marshall, PhD

Jason Marshall is the author of The Math Dude's Quick and Dirty Guide to Algebra. He provides clear explanations of math terms and principles, and his simple tricks for solving basic algebra problems will have even the most math-phobic person looking forward to working out whatever math problem comes their way.