Half adders and full adders
How a handful of logic gates add binary numbers: one XOR and one AND add two bits, a full adder handles the carry, and a chain of them adds 6 + 7.
In 30 seconds
Adding two bits gives a sum bit and a carry bit. An XOR gate produces the sum and an AND gate produces the carry; together they are a half adder.
A full adder also accepts a carry coming in from the column to its right, so it adds three bits. It is two half adders plus an OR gate.
Line up one full adder per column and pass each carry-out to the next carry-in, and you can add numbers of any width. That chain is a ripple-carry adder.
Half adders and full adders, step by step
Ripple-carry is the simplest adder. Real processors use faster designs, such as carry-lookahead, that work out the carries in parallel; the full-adder logic is the same.
- Step 1: Adding two bits. Adding two single bits has only four cases. Three of them fit in one digit. The fourth, 1 + 1, makes two, which binary writes as 10: a 0 in this column and a 1 carried to the column on the left, just as 5 + 5 in decimal leaves 0 and carries 1.
- Step 2: One gate per output. Write the four cases as a table with two outputs. The SUM column is 1 exactly when the inputs differ: that is the XOR gate. The CARRY column is 1 only when both inputs are 1: that is the AND gate. So two gates are enough to add two bits.
- Step 3: The half adder. Feed the same two bits into an XOR and an AND and you have a half adder: two inputs, two outputs. Here it adds 1 + 1. XOR says the sum bit is 0, AND says there is a carry, and the pair reads 10.
- Step 4: A third bit arrives. In a longer sum, most columns receive a carry from the column on their right, so they must add three bits, not two. A half adder has nowhere to plug that carry in. The circuit that takes A, B and a carry-in (Cin) is the full adder; its table has eight rows.
- Step 5: The full adder. A full adder is two half adders and an OR gate. The first adds A and B. The second adds Cin to that sum, which gives the final SUM. If either half adder produced a carry, the OR passes it on as the carry-out (Cout). The two can never both carry at once.
- Step 6: Chain four of them. To add 4-bit numbers, use one full adder per column and connect each carry-out to the carry-in of the column on its left. The rightmost column has no neighbour, so its carry-in is fixed at 0. This is a ripple-carry adder, loaded here with 0110 (6) and 0111 (7).
- Step 7: The carry ripples. The 1s column gives sum 1, no carry. The 2s column adds 1 + 1: sum 0, carry 1. The 4s column adds 1 + 1 + 1: sum 1, carry 1. The 8s column adds 0 + 0 + 1: sum 1. The result 1101 is 13. Each column must wait for its neighbour, so wide ripple adders are slow; fast processors compute the carries ahead.
Try it yourself
Learn this first
Spotted a mistake on this page?