Adding Binary Numbers and Overflow
Adding binary numbers column by column with a carry, and what happens when the answer needs more bits than the space it has.
What a learner can do afterwards
- Add two 8-bit binary numbers, carrying correctly
- Spot an addition whose result no longer fits in 8 bits
- Describe what a program shows when a value overflows
1 · Read
Binary addition uses only 0 and 1. Add the rightmost column first, then move left. When a column totals 2, write 0 and carry 1. When two input 1s and an incoming carry total 3, write 1 and carry 1.
A carry always moves one column left. For example, the carry from the ones column joins the twos column before that column is added.
Add 01101101 and 01011010 from right to left. The result is 11000111, which is 199 in decimal.
Eight bits make 256 patterns, from 0 through 255. The number 256 needs a ninth bit, so it cannot be stored as an unsigned 8-bit value.
If a result needs a ninth bit but storage is fixed at 8 bits, the low 8 bits remain and the extra carry is discarded. This is overflow. A program may wrap to a small value, report an error, or use a larger number type.
255 is 11111111 in binary. Adding 1 gives 1 00000000. If only eight result bits are kept, the leading 1 is discarded and 00000000 remains.
For 1111 + 1, start at the right. Each 1 plus the incoming carry makes 0 and passes a carry left. The final carry creates 10000.
Add from right to left, carry into the next column, and check whether the result needs more bits.
Original lesson wording, examples, assessment items, and worked steps authored for the P12 computing curriculum.
Enrichment facts and media are adapted from the cited source records; revised cards and the other reading wording were authored for the P12 computing curriculum. The rewritten reading 'Add Bits and Carry' was written for this dataset.
2 · Watch
Take it off screen
Where it sits
8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.