WHY 2's-COMPLEMENT?

The general problem is in the process of (decimal) subtraction:

Assume that A and Bare positive (decimal) digits. THEN:

A - B is equal to A -10 + (10 - B)
where (10 - B) is known as the "10's complement" of B.

THEN:

(10 -B) = ((9 - B) + 1)

(9 - B) is the "9's complement" of B that can be easily computed from the following table:

Digit
9's Complement
0
9
1
8
2
7
3
6
4
5
5
4
6
3
7
2
8
1
9
0

For any decimal value of X and Y not greater than 99999 we can show that:

X + Y is equal to X - 100000 + (100000 - abs(Y))
That is, X - 100000 + (99999 - abs(Y) + 1)

Where 99999 - abs(Y) = 9's complement of Y
and
(99999 - abs(Y) + 1) is the 10's complement of Y
(Note that the additive factor is of magnitude 10 times the largest of X or Y)

For binary representation in the computer the problem is easier since (a) the number of digits is only 2, and (b) and we always know how many digits are in each representation. The two complementary representations are called "2's complement" and "1's complement".

Digit
1's Complement
0
1
1
0

and the 2's complement is simply the 1's complement plus 1!

EXAMPLES OF 2's COMPLEMENT REPRESENTATION:

2710 = 00110112
- 2710 = 11001002 + 1 = 11001012

3610 = 01001002
- 3610 = 10110112 + 1 = 10111002

Last updated 2001/10/18