# 1's complement addition of outer carry to the result

Let's take for example this addition: 3 + (-1).

• 1 in binary is 001, and to obtain it's 1's complement counterpart we flip the bits. So it is: 110.

• 3 in binary is 011.

011 + 110 = 1001

That first 1 which is in bold has to be added to the number formed by the last 3 bits as follows:

001 + 1 = 010 (2 in decimal).

Why do we do the last step, adding that outer carry? Which is the logic behind?

Computers represent numbers (and other things) imperfectly, sometimes for convenience, sometimes because there is no alternative. Complement arithmetic is easier to implement than sign-magnitude, but has a few quirks.

We just live with them, there's nothing special here.

In two's complement, the "extra one" is also there, but it is added during the change of sign, and because there is only one representation for zero, the system is a bit more elegant.

Try to picture a base complemented number as representing what's missing in the number to reach $b^k$ ($b$ is the base, $k$ is the number of significant digits). The apparent "extra one" is due to the fact that what is counted here are the steps to reach the implicit "zero" in $b^k$.

For instance, in ten's complement, with $k=3$:

$-5 = 995=10^3\color{red}{-5}$

In nine's complement, $999$ is zero, so the extra one is not necessary in this case. It becomes necessary, though, when the operation causes overflow due to change of sign:

$-5 = 994$

$-5+6 = 994+006 =\color{red}{1}000\color{blue}{+1} = 001$

• If the quirks are so obscure for an answer to be found, I could live without it, sure. – Iulian Barbu Oct 18 '16 at 9:12
• It is not obscure, it just has no special meaning. I've edited my answer, hope it satisfies your curiosity. – André Souza Lemos Oct 18 '16 at 13:53
• I think I understand your point. The addition implies some kind of circularity. I could also say, the newly formed number, whose representation exceed the k bits representation, k, must be kept intact and used in the following substraction, which will give the final answer: 1000 - 999 (maximum in 10 base, which also means 0) = 1. Instead of 1000, we could have any result from adding two numbers in base b complement, but the final result will be result - (the maximum number in b base, which is 0 in b's complement). – Iulian Barbu Oct 18 '16 at 17:41
• Exactly. There is a distant connection with modular arithmetic. – André Souza Lemos Oct 18 '16 at 17:47

I only understand two's complement

Let's take two 3 bits numbers, X and Y

Complementing the bits is like calculating 111-X

(it is obvious as $\overline {b} = 1-b$, $\sum_{i=0}^n 2^i*(1-b_i) = \sum_{i=0}^n 2^i - \sum_{i=0}^n 2^i*b_i$...)