On this page
Inside your phone or laptop, adding two numbers comes down to logic gates working on binary digits. The basic design is the same column addition you learnt in primary school, done in base 2.
How does a computer add using logic gates?
A key step towards building arithmetic from switches was Claude Shannon's paper "A symbolic analysis of relay and switching circuits", published in the Transactions of the American Institute of Electrical Engineers in December 1938. Based on his MIT master's thesis, it showed that Boolean algebra could simplify arrangements of relays. The counting system itself is older: our post on Leibniz's 1703 binary arithmetic tells that story.
University of Glasgow lecture notes on binary addition cover the three pieces you need: a half adder adds two bits, a full adder adds two bits plus a carry, and chained full adders add longer numbers.
What is a half adder?
A half adder adds two bits, x and y, giving a sum bit s and a carry bit c:
x = 0, y = 0: c = 0, s = 0
x = 0, y = 1: c = 0, s = 1
x = 1, y = 0: c = 0, s = 1
x = 1, y = 1: c = 1, s = 0
Read the last line as "1 + 1 = 10 in binary": write 0, carry 1. The carry is 1 only when both inputs are 1, so c = x AND y. The sum is 1 when exactly one input is 1, so s = x XOR y. As the Glasgow notes put it, one AND gate and one XOR gate make a half adder. For practice with gate outputs, see our guide to drawing AND, OR, NAND and NOR output waveforms.
What does a full adder do that a half adder can't?
A half adder only works for the rightmost column. Every other column has three things to add: x, y and the carry coming in from the column to its right (c_in). A full adder takes all three and gives a sum s and a carry-out c_out. Its eight-row truth table, grouped by how many inputs are 1:
0 + 0 + 0: c_out = 0, s = 0
one input is 1: c_out = 0, s = 1
two inputs are 1: c_out = 1, s = 0
all three are 1: c_out = 1, s = 1
The outputs, read as a 2-bit number c_out s, are simply the count of 1s at the inputs: three 1s give 11. In gates, s = x XOR y XOR c_in, and c_out is 1 when at least two inputs are 1 (the "majority" function).
The neat way to build it, from the same Glasgow notes:
The first half adder adds x and y, giving a partial sum and a first carry.
The second half adder adds that partial sum and c_in, giving the final sum s.
An OR gate combines the two carries into c_out (both can never be 1 at once).
The Glasgow notes count 2 AND, 2 XOR and 1 OR gate in this design. Every gate can be built from NAND alone (see our post on making NOT, AND and OR from only NAND gates), so a whole adder can use one kind of gate.
How do you chain full adders to add 4-bit numbers?
Place four full adders side by side, one per column. The carry-out of each feeds the carry-in of the next one to its left, and the carry-in of the rightmost adder is fixed at 0, as the Glasgow notes describe. This is called a ripple carry adder, because the carry ripples from right to left.
Worked example: add 1011 (11) and 0110 (6). Right to left:
Column 0: 1 + 0 + 0 (carry-in fixed at 0) = 01, so s = 1, carry 0.
Column 1: 1 + 1 + 0 = 10, so s = 0, carry 1.
Column 2: 0 + 1 + 1 = 10, so s = 0, carry 1.
Column 3: 1 + 0 + 1 = 10, so s = 0, carry 1.
The last carry-out becomes the fifth bit, so the answer is 10001, which is 16 + 1 = 17. Check: 11 + 6 = 17.
Why does a ripple carry adder get slow?
Real gates take a short time to switch, and each carry must pass through every adder before it, so longer numbers mean longer delays. The Glasgow notes say this doesn't matter for small adders but can for long words in a fast processor, where lookahead carry designs use shortcuts to work out carries without passing them along.
Try it yourself:
Write the eight-row full adder table from memory, then check it by counting 1s.
Add 0111 + 0101 column by column and mark where each carry goes.
If a step trips you up, Fermi's AI tutor can work out what you already know, build a plan for the session and teach through it, writing on a board and drawing the figure as it goes. For the gates themselves, the Fermi Concept Library covers every concept in physics, chemistry, biology, mathematics and computing.



