Column addition
Each lamp is one bit: lit is 1, dark is 0. From the right, the columns are worth one, two, four and eight. So A = 0110 is 4 + 2 = 6 and B = 0111 is 4 + 2 + 1 = 7.
Each column gets one full adder. It adds three bits, A, B and a carry-in, and gives a sum bit and a carry-out. Each carry-out is wired to the next adder's carry-in. The first carry-in is fixed at 0.
The carry ripples
The ones column adds A = 0, B = 1 and the carry-in 0. The total is 1, so the sum bit is 1 and the carry-out is 0. Even a 0 carry still has to travel to the next adder.
The twos column adds 1 + 1 + 0 = 2. Two is written 10 in binary, so the sum bit is 0 and a carry of 1 moves left, just like carrying a ten on paper.
The fours column had to wait for that carry. Now it adds 1 + 1 + 1 = 3, which is 11 in binary: sum bit 1, carry-out 1.
The eights column adds 0 + 0 + 1 = 1: sum bit 1, carry-out 0. The carry has rippled through all four adders, one after another. That is why this circuit is called a ripple-carry adder.
Read the sum lamps from left to right: 1101. That is 8 + 4 + 0 + 1 = 13, the same answer as on paper, because the adders do column addition just the way we do.
Speed and limits
Every adder waits for the carry from its right before its answer is final. So the time grows with the number of bits: 4 bits means 4 adders in turn, and a 64-bit ripple adder would wait for 64.
So wide adders, like the 64-bit ones in processors, use faster designs such as carry-lookahead. Extra logic looks at all the A and B bits at once and works out every carry together, instead of passing it along.
Now add 9 + 9 = 18. Four bits only hold 0 to 15. The last adder's carry-out is 1, but there is no fifth sum lamp to keep it, so the lamps read 0010, which is 2. This is called overflow.
Column by column
;; step 1/10 · six-plus-seven ;; about: On paper, Eights column, Fours column, Twos column, Ones column A = 0110 = 0·8 + 1·4 + 1·2 + 0·1 = 6 B = 0111 = 0·8 + 1·4 + 1·2 + 1·1 = 7 On paper we add binary numbers like decimal ones: column by column from the right, carrying when a column has more than one 1 to write down.
In a real chip each bit is a high or low voltage on a wire; here a glowing lamp or token shows a 1. A lit wire with moving dashes carries a 1. In Python, (a >> i) & 1 reads bit i of a, and ^, & and | on the numbers 0 and 1 work as XOR, AND and OR. Python's own integers never overflow: the 4-bit limit here is the size of the circuit, not of Python.