← r0mheat z80 lessons: all projects

Binary addition: How carry works

Add one bit at a time. A carry moves from a small place value to the next one.

Number basics

1 + 1 = 10₂

In one binary place, 1 + 1 makes 0 and carries 1 to the next place. The subscript 2 means “this number is binary.”

What the column sum means

For one column, add the A bit, the B bit and the carry from the previous column. This small sum can be 0, 1, 2 or 3. Write its rightmost binary digit. Carry its left digit to the next column.

0 + 0 + 0 = 0 = 0₂Write: 0 Carry: 0
0 + 1 + 0 = 1 = 1₂Write: 1 Carry: 0
1 + 1 + 0 = 2 = 10₂Write: right digit 0 Carry: left digit 1
1 + 1 + 1 = 3 = 11₂Write: right digit 1 Carry: left digit 1
Example
Run speed

Add these bytes

One column per step

BitPlace valueABCarry inColumn sumResult bitCarry out

“Carry in” is the value (0 or 1) passed from the previous column. “Column sum” is A + B + carry in, shown in decimal and binary. The left digit is the carry out.

Full sum

The leftmost slot is carry out from bit 7. It is not part of the 8-bit result.

Simplification: this example adds unsigned 8-bit values. It shows carry out. It does not model the Z80 flags yet.