binary-addition

Intro

Unlike human math, which is based on the number 10 (a result of having five fingers on each hand), computer math is based on the number 2 — which has the values of 0 and 1. So how do you do math using just nothing and something? The same way it's done using the numbers 0 through 9. The only difference is in the way the 1s and 0s are moved around to fill the needs of borrow and carry.

All binary math operations are built around just two basic circuits: the binary adder and the shift register. While both circuits are made up of several more elementary logic gates, the focus will be on how these two functions perform as a unit. I won't take a microscopic tour of each electron's movement. Instead, I'm going to tell you how to wire the functions together and just what to expect when you flip the switch.

Binary Addition

Half Adder

The half adder adds two single binary digits A and B. It has two outputs, sum (S) and carry (C). The carry signal represents an overflow into the next digit of a multi-digit addition.

Basic to all math operations is the binary adder, which comes in two flavors: a half adder and a full adder. The half adder simply tallies two binary bits and outputs a sum.

0+0=0{0}+{0}={0}

1+0=1{1}+{0}={1}

0+1=0{0}+{1}={0}

Nothing surprising here. But what happens when you add 1+1{1}+{1}? Exactly the same thing that happens when you add 9 + 1 — you get 10. Like decimal addition, binary addition carries over the next most significant digit when the total exceeds the base number. For logic circuits, that's when the sum exceeds 1, whereupon the most-significant digit (MSB) is shifted left one position and a place holder (0) fills the least-most significant (LSB) position. Consequently, the sum of 1+1=10{1}+{1}={10}.

Full Adder

A full adder adds binary numbers and accounts for values carried in as well as out. A one-bit full-adder adds three one-bit numbers, often written as A{A}, B{B}, and Cin{{C}_{{{i}{n}}}^{}}; A{A} and B{B} are the operands, and Cin{{C}_{{{i}{n}}}^{}} is a bit carried in from the previous less-significant stage. The full adder is usually a component in a cascade of adders, which add 8, 16, 32, etc. bit binary numbers. The circuit produces a two-bit output.