Every calculation a computer does comes down to adding bits. Inside the processor, a circuit called an adder adds two binary numbers column by column, just as you add on paper, but it only has room for a fixed number of bits. In this lesson you will add binary numbers by hand, see the logic gates that do it in hardware, find out what happens when the answer is too big for its register (overflow), and watch the same thing happen in C. It follows on from Power Protection and Types of Computers, and it builds on word size from Memory Types and Features.
What you will learn
- The four rules for adding one column of bits, plus the rule for a column with a carry in.
- How to add two 4-bit or 8-bit numbers, showing every carry, and how to check the answer in decimal.
- How a half adder and a full adder are built from logic gates, and how full adders join to make a ripple-carry adder.
- What overflow is, how to spot it, and the range of unsigned numbers that n bits can hold.
- How C stores the result of adding two unsigned values, and why it can print an answer that looks wrong.
Part 1: A quick reminder about place values
In binary, each column is worth twice the column to its right: 1, 2, 4, 8, 16, 32, 64, 128 and so on. To read a binary number, add the place values of the columns that hold a 1. For example, 0110 1101 = 64 + 32 + 8 + 4 + 1 = 109. We write long binary numbers in groups of four bits so they are easier to read. (If you need more practice converting, see Decimal to binary and Binary Manipulation.)
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 109 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
| 59 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
Part 2: Adding binary numbers by hand
The rules for one column
There are only two digits, so a column fills up quickly. As soon as a column adds up to 2 or more, you write down the units digit and carry 1 to the next column on the left, exactly like carrying a ten in decimal.
| In the column | Total in decimal | In binary | Write | Carry |
| 0 + 0 | 0 | 0 | 0 | 0 |
| 0 + 1 or 1 + 0 | 1 | 1 | 1 | 0 |
| 1 + 1 | 2 | 10 | 0 | 1 |
| 1 + 1 + carry 1 | 3 | 11 | 1 | 1 |
The last row matters most. Every column except the rightmost one may receive a carry from the right, so it can have three bits to add. The total is never more than 3, so the carry out of a column is never more than 1.
Worked example 1: a 4-bit sum
Add 0101 (5) and 0011 (3). Write the carries above the columns as you go, starting from the right.
Carry 1 1 1
A 0 1 0 1 (5)
B + 0 0 1 1 (3)
-------
Sum 1 0 0 0 (8)
- Column 1 (value 1): 1 + 1 = 2 = binary 10. Write 0, carry 1.
- Column 2 (value 2): 0 + 1 + carry 1 = 2. Write 0, carry 1.
- Column 3 (value 4): 1 + 0 + carry 1 = 2. Write 0, carry 1.
- Column 4 (value 8): 0 + 0 + carry 1 = 1. Write 1, carry 0.
- Check: 1000 = 8, and 5 + 3 = 8. ✔
Notice how one carry can travel (“ripple”) through several columns. Keep that picture in mind: it is exactly how the hardware adder in Part 3 works.
Worked example 2: an 8-bit sum
Add 0110 1101 (109) and 0011 1011 (59).
Carry 1111 111
A 0110 1101 (109)
B + 0011 1011 (59)
---------
Sum 1010 1000 (168)
Every column from the right produces a carry until the leftmost column, which has 0 + 0 + carry 1 = 1 and so carries nothing out. Check: 1010 1000 = 128 + 32 + 8 = 168, and 109 + 59 = 168. ✔ Step through this sum yourself in Try it 1, then try your own numbers.
Always check in decimal. Convert both numbers and the answer to decimal. If the decimal sum does not match, look for a column where you forgot a carry. That is the most common mistake.
Try it 1Column-by-column binary adder
Choose a size, type two whole numbers (or tap Random), then tap Next column. The adder works from the right, exactly as you would on paper, and shows every carry. Turn on Predict mode to work out each column yourself before it is shown.
Part 3: Adders in hardware
The processor’s arithmetic logic unit (ALU) adds with logic gates. If the gates are new to you, read Logic Gates – Formal Introduction first. Look back at the column rules and compare them with the gate truth tables:
- The bit you write is 1 when exactly one of the two bits is 1. That is the XOR gate.
- The bit you carry is 1 only when both bits are 1. That is the AND gate.
Half adder
A half adder adds two bits, A and B. It has two outputs: Sum = A XOR B, and Carry = A AND B. It is called "half" because it has no input for a carry coming from the right, so it can only be used for the rightmost column.

| A | B | Sum (A XOR B) | Carry (A AND B) |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Full adder
A full adder adds three bits: A, B and the carry in (Cin) from the column on the right. It can be built from two half adders and an OR gate:
- Sum = A XOR B XOR Cin (the sum is 1 when an odd number of the inputs are 1).
- Carry out = (A AND B) OR ((A XOR B) AND Cin) (the carry is 1 when at least two of the inputs are 1).

| A | B | Cin | Sum | Cout |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Read each row as an ordinary sum and the table makes sense: the two outputs, Cout then Sum, are just the total of the three inputs written in binary. For example, the last row is 1 + 1 + 1 = 3 = binary 11.
Try it 2Half adder and full adder explorer
Choose the circuit, then tap the inputs to switch them between 0 and 1. The outputs, the gate-by-gate working and the matching row of the truth table update straight away.
Ripple-carry adder
To add two 8-bit numbers, chain 8 full adders side by side, one per column. The carry out of each adder is wired to the carry in of the adder on its left. (The rightmost adder’s carry in is set to 0, or it can be a half adder.) This is a ripple-carry adder, because a carry may have to ripple through every stage before the answer is ready. That is exactly what you saw in Worked example 2. The two numbers usually come from registers, and the answer is stored in a register, which is a row of flip-flops like the one in The SR Latch.
Wider adders are slower, because the last column has to wait for the carry to arrive. Real processors use faster designs (such as carry-lookahead adders), but CAPE expects you to know the half adder, the full adder and how they are joined.
Part 4: Fixed width and overflow
A register, and an adder, has a fixed number of bits. That number is usually the processor’s word size (see Memory Types and Features). With n bits, the unsigned whole numbers you can store go from 0 to 2n − 1.
| Bits (n) | Number of patterns (2n) | Unsigned range |
| 4 | 16 | 0 to 15 |
| 8 | 256 | 0 to 255 |
| 16 | 65,536 | 0 to 65,535 |
| 32 | 4,294,967,296 | 0 to 4,294,967,295 |
Adding two n-bit numbers can give an answer that needs n + 1 bits. If the register has only n bits, the extra bit (the carry out of the leftmost column) is lost. This is called overflow.
Worked example 3: overflow in 8 bits
Add 1100 1000 (200) and 0110 0100 (100) in an 8-bit register.
Carry 1 1
A 1100 1000 (200)
B + 0110 0100 (100)
---------
Full 1 0010 1100 (300)
Kept 0010 1100 (44)
The true answer, 300, needs 9 bits. The register keeps only the lowest 8 bits, 0010 1100, which is 44. The 256 that the lost carry was worth has gone: 300 − 256 = 44.
Rule for unsigned numbers: the addition overflowed if, and only if, there is a carry out of the leftmost column. A 1 in the leftmost sum bit is not overflow. For example, 0100 + 0100 = 1000 (4 + 4 = 8) fits in 4 bits.
A look ahead. When the same bits stand for signed numbers (two’s complement, the next lesson), the rule changes: the carry out is simply thrown away, and overflow happens when two numbers with the same sign give an answer with the other sign. Try it 3 shows both readings so that you can compare them.
Try it 3Overflow checker
Pick a register size and two unsigned numbers. The checker shows the full sum, what the register can keep, and whether the addition overflowed. Or tap one of the examples.
Part 5: Binary addition in C
C variables have fixed widths too. On most computers an unsigned char has 8 bits, an unsigned short has 16 bits and an unsigned int has 32 bits. When the total of an unsigned addition is too big, C does what the hardware does: it keeps the lowest bits and drops the carry. (If printf and format specifiers are new to you, see Variables, format specifiers and printf.)
#include <stdio.h>
int main(void)
{
unsigned char a = 200; /* 1100 1000 */
unsigned char b = 100; /* 0110 0100 */
/* sum keeps only 8 bits */
unsigned char sum = a + b;
/* full has room for the carry */
unsigned int full = a + b;
printf("Full total: %u\n", full);
printf("Kept in 8 bits: %d\n", sum);
if (full > 255)
printf("Overflow: carry lost\n");
return 0;
}
Output:
Full total: 300 Kept in 8 bits: 44 Overflow: carry lost
a + b is worked out in a wider type (C first turns small types into int), so full really is 300. When the result is stored in the 8-bit sum, only the lowest 8 bits fit, so it becomes 44. That is Worked example 3 again. For unsigned types, C guarantees this wrap-around: the result is the remainder after dividing by 2n.
Warning about signed types. If a signed int overflows, the C standard says the behaviour is undefined: the program may print a strange number, or the compiler may assume it never happens. Use unsigned types when you want wrap-around, and check ranges before you add.
Try it 4What will C print?
Choose an unsigned C type and two values. The program and its output change to match. Tap Add 1 to a again and again near the top of the range to watch the value wrap around, like a car’s odometer rolling over.
Output:
A ripple-carry adder in C
This program adds two 8-bit numbers the way the hardware does: one column at a time, from right to left, passing the carry along. Each pass of the loop is one full adder. The bits are kept in arrays (see Arrays in C), with bit 0, the rightmost bit, stored first.
#include <stdio.h>
int main(void)
{
/* Bit 0 (the rightmost bit) is */
/* stored first, so the bits look */
/* backwards. */
/* 0110 1101 = 109 */
int a[8] = {1,0,1,1,0,1,1,0};
/* 0011 1011 = 59 */
int b[8] = {1,1,0,1,1,1,0,0};
int sum[8];
int carry = 0;
int total, i;
/* one full adder per column, */
/* from right to left */
for (i = 0; i < 8; i++)
{
/* total is 0, 1, 2 or 3 */
total = a[i] + b[i] + carry;
sum[i] = total % 2; /* write */
carry = total / 2; /* carry */
}
printf("Sum: ");
for (i = 7; i >= 0; i--)
printf("%d", sum[i]);
printf("\nCarry out: %d\n", carry);
return 0;
}
Output:
Sum: 10101000 Carry out: 0
That is 168, the answer to Worked example 2. Notice that total % 2 gives the sum bit and total / 2 gives the carry, the same as reading the full adder truth table as an ordinary sum. Change the arrays to hold 200 and 100 and run it again: the carry out becomes 1, which means overflow.
Summary
| Idea | Key points |
| Column rules | 0+0 = 0; 0+1 = 1; 1+1 = 10 (write 0, carry 1); 1+1+1 = 11 (write 1, carry 1). Work from the right. |
| Checking | Convert both numbers and the answer to decimal. |
| Half adder | Two inputs. Sum = A XOR B; Carry = A AND B. No carry in. |
| Full adder | Three inputs (A, B, Cin). Sum = A XOR B XOR Cin; Cout = (A AND B) OR ((A XOR B) AND Cin). |
| Ripple-carry adder | n full adders in a chain; each carry out feeds the next carry in. |
| Unsigned range | n bits hold 0 to 2n − 1. |
| Overflow (unsigned) | A carry out of the leftmost column. The register keeps only the lowest n bits. |
| C | Unsigned types wrap around (the result is the remainder after dividing by 2n). Signed overflow is undefined behaviour. |
Practice questions
1. Add 1011 0110 and 0101 1101, showing your carries. Give the answer in binary and in decimal, and say whether it fits in 8 bits.
Show answer
182 + 93 = 275. Full answer: 1 0001 0011 (9 bits). It does not fit in 8 bits: an 8-bit register keeps 0001 0011 = 19, so there is an overflow (275 − 256 = 19).
2. Explain the difference between a half adder and a full adder.
Show answer
A half adder adds two bits and gives a sum and a carry; it has no carry input. A full adder adds three bits (A, B and a carry in from the column on the right), so it can be used for every column of a multi-bit addition.
3. Write Boolean expressions for the Sum and Carry out of a full adder with inputs A, B and Cin.
Show answer
Sum = A XOR B XOR Cin. Cout = (A AND B) OR ((A XOR B) AND Cin). (Cout = AB + ACin + BCin is also correct.)
4. How many full adders are needed in a ripple-carry adder for two 16-bit numbers? Why is it called "ripple-carry"?
Show answer
16 full adders (or 15 full adders and a half adder for the rightmost bit). A carry produced in one column may travel, or ripple, through every stage to the left before the final answer is ready.
5. A 4-bit register holds 1101. The value 0101 is added to it. What does the register hold afterwards, and has overflow happened? Treat both as unsigned.
Show answer
13 + 5 = 18 = 1 0010. The register keeps 0010 (2). There is a carry out of the leftmost column, so an unsigned overflow has happened.
6. State the range of unsigned whole numbers that 12 bits can hold. What is the smallest number of bits needed to store 1000?
Show answer
0 to 4095 (212 − 1). 1000 needs 10 bits, because 29 − 1 = 511 is too small and 210 − 1 = 1023 is big enough.
7. In C, unsigned short s = 65535; is followed by s = s + 1;. On a computer with 16-bit shorts, what is the value of s? Explain.
Show answer
0. 65535 is 1111 1111 1111 1111, the largest 16-bit unsigned value. Adding 1 gives 1 0000 0000 0000 0000 (65536), which needs 17 bits. Only the lowest 16 bits are kept, which are all 0.
8. Explain why the sum of two n-bit unsigned numbers never needs more than n + 1 bits.
Show answer
The largest n-bit number is 2n − 1. The biggest possible sum is 2 × (2n − 1) = 2n+1 − 2, which is less than 2n+1, so it always fits in n + 1 bits. That is why each column carries at most 1.
Homework
- Make up three pairs of 8-bit numbers: one whose sum fits easily, one that only just fits (a total of exactly 255) and one that overflows. Add each pair by hand, showing the carries, then check them with Try it 1 and Try it 3.
- Draw a 4-bit ripple-carry adder as four boxes labelled "Full adder". Label every input and output, and show where the carries go. Then trace 0111 + 0110 through your diagram, writing the value on every wire.
- Copy the ripple-carry program into Code::Blocks. Change it so that it also converts the sum back to decimal and prints it. (Hint: add 2 to the power of i for every sum bit that is 1.)
Exam tips
- 2009 Unit 1 Paper 02, Question 1(d)(ii). This part asks you to add two 4-bit binary numbers whose total does not fit in 4 bits. It tests careful column-by-column carrying and whether you notice that the answer has grown to five bits. Show your carry row, give the full answer, and say in words that it cannot be stored in four bits. The other parts of 1(d) move on to reading binary in decimal, the largest and smallest values in four bits, and two’s complement, so revise them together. Try it yourself first, then compare with the solution on this site: 2009 U1 Q1.
- Specimen Unit 1 Paper 01 (2021), Item 5. A multiple-choice item on what the term word size means. It tests whether you know that the word size is the number of bits the processor handles at once, which is also the width of its registers and adder and so sets the overflow limit in this lesson. Open the specimen paper and try it before you check the key.
- Coming next: Specimen Unit 1 Paper 01 (2021), Items 1 and 2, and 2024 Unit 1 Paper 02, Question 2(c). These give an 8-bit pattern or a negative number and ask about its signed magnitude or two’s complement form, or about the range of signed values in 8 bits. They belong to the next lesson, but they rely on the fixed-width addition you practised here. See the solution 2024 U1 Q2 once you have tried it.
- Half and full adders. Adders are named in the syllabus (Unit 1, Module 1, Specific Objective 2), but I have not found a question on them in the past papers, specimen papers or solutions on this site so far. Learn the two truth tables and the Boolean expressions anyway, and be ready to draw both circuits.
- More worked answers are on the CS Solutions page.
General advice (from the lesson content, not from a particular paper): always show the carry row; write binary in groups of four; check every answer in decimal; and when a question gives a number of bits, keep exactly that many bits and say clearly whether the answer overflowed.
Previous: Power Protection and Types of Computers. Related: Memory Types and Features (word size) and The SR Latch (how a register stores bits). Next: signed numbers, two’s complement and signed overflow (coming soon in this course). For extra practice now, see Binary Manipulation and the Data Representation Homework Exercise.
Syllabus link: CAPE Computer Science (CXC A19/U2/21), Unit 1, Module 1: Computer Architecture. Specific Objective 2: describe the basic building blocks of a computer (truth tables; logic gates; adders). Specific Objective 3: interpret the interaction among the basic building blocks of a computer (logic gates, registers). Specific Objective 4: explain how data is represented in a computer system (bits; bytes; number bases). U1 M1 SO2, SO3, SO4.
Video search terms
Search YouTube for: "binary addition with carries", "half adder and full adder explained", "ripple carry adder", "unsigned integer overflow".
Try it 5Quick quiz
Tap an answer. All eight questions are self-checks on this lesson.
Attributions to media used in this post:
Half adder diagram: Inductiveload, public domain, via Wikimedia Commons (File:Half Adder.svg).
Full adder diagram: Inductiveload, public domain, via Wikimedia Commons (File:Full-adder logic diagram.svg).
Updates
11 Nov 2026
- Draft created.
© 2026 Vedesh Kungebeharry. All rights reserved.



