Level 0: How computers work · 14 min
Full adder: adding bigger numbers
Goal: add three bits, then add whole numbers.
You need: Half adder.
An easy start: add on paper
Add 27 + 15 on paper.
- Right column: 7 + 5 = 12. Write 2, carry 1.
- Left column: 2 + 1 + the carried 1 = 4.
The answer is 42. In step 2 you added three things. A computer must do that too.
Three inputs, two outputs
A full adder takes three bits:
- A and B: the two bits in this column.
- Carry in: the carry arriving from the column on the right.
It gives two bits: the sum for this column and the carry out for the next one.
You only need to count how many inputs are 1:
| Inputs that are 1 | Carry out | Sum | Means |
|---|---|---|---|
| none | 0 | 0 | zero |
| one | 0 | 1 | one |
| two | 1 | 0 | two |
| all three | 1 | 1 | three |
Build it from parts you know
Adding three numbers in your head, you add two first, then add the third. The circuit does the same.
- First half adder: add A and B.
- Second half adder: add that sum and the carry in. Its sum is the final sum.
- OR gate: if either half adder made a carry, the carry out is 1.
The picture below shows 1 + 1 + 1.
Can both half adders make a carry at once? No. If the first one makes a carry, its sum is 0, so the second one adds 0 and cannot carry.
Try it
Switch on the inputs one at a time. Watch each of the three steps.
- First half adder: 0 and 0 give sum 0, carry 0
- Second half adder: 0 and 0 give sum 0, carry 0
- OR gate: 0 or 0 gives 0
Sum 0 · Carry out 0
0 + 0 + 0 = 0, which is 00 in binary.
Adding whole numbers
Now put full adders in a row, one for each column. Connect each carry out to the carry in of the column on its left. The rightmost column has nothing before it, so its carry in is 0.
This chain is called a ripple-carry adder, because the carry moves like a ripple from right to left.
A worked example: 5 + 3
5 is 0101 and 3 is 0011. Start at the right (the column worth 1) and move left.
| Column | Adds | Sum | Carry out |
|---|---|---|---|
| 1 | 1 + 1 + 0 | 0 | 1 |
| 2 | 0 + 1 + 1 | 0 | 1 |
| 4 | 1 + 0 + 1 | 0 | 1 |
| 8 | 0 + 0 + 1 | 1 | 0 |
Read the sum bits from the bottom row to the top: 1000. That is 8. Correct!
Add your own numbers
Tap the bits of A and B. Try 5 + 3, then 7 + 1, then 15 + 1. Watch the carry row.
Last carry: 0. 5 + 3 = 8, which is 01000 in binary.
When the answer does not fit
Four bits can hold 0 to 15. But 15 + 1 = 16, which is 10000: five bits. The extra 1 is the last carry. If there is no room to keep it, the stored answer would be 0000. This is called overflow.
Real processors usually work with 32 or 64 bits at a time. Many also use faster designs than a simple ripple, but the idea of sum and carry is the same.
Check yourself
Practice
Add 0110 and 0111 one column at a time. Write the carry for each column. Then check your answer in decimal.
Show answer
From the right: column 1: 0 + 1 + 0 gives sum 1, carry 0 column 2: 1 + 1 + 0 gives sum 0, carry 1 column 4: 1 + 1 + 1 gives sum 1, carry 1 column 8: 0 + 0 + 1 gives sum 1, carry 0 Answer: 1101. In decimal, 6 + 7 = 13.
Recap
- A full adder adds A, B and a carry in.
- It is made from two half adders and an OR gate.
- A chain of full adders adds whole numbers, passing the carry to the left.
- If the answer needs more bits than there is room for, that is overflow.