# 2's Complement Binary Numbers

Choose Subtopic

### Two's Complement Binary

Two's Complement signed integers use a coding that is intuitive for positive numbers but that takes some getting used to for negative numbers. If the most significant (left-most) bit is 0, the number is construed as positive, and the coding looks just like straight binary. If the lead bit is 1, the number is negative, but not just reading the bits is misleading. To convert a binary number from positive to negative, we Complement (change all the 0's to 1's) and Increment (add 1). We can go from negative to positive the same way. Here's an example (using 4 bits again).

+6 = 0110.

Complement → 1001

Increment → 1010

Why would we want to use 1010 = -6. First, let's demonstrate that complement + increment returns +6 as an answer:

Complement → 0101

Increment → 0110

What should happen if we add + 6 and -6? We should get 0, regardless of how we write the problem. What happens if, in the middle of our calculations, we ignore the meaning of place value and simply add the representation for + 6 and the representation for -6 AS IF the most significant bit were just like all the others?

0110

__+ 1010__

1 0000

The addition overflowed into the 5th bit, but the lower 4 bits give us 0. What we have shown is that subtraction in the two's complement system can be done using addition. In designing digital electronics, this is a huge simplification. Let's try 6-5

6: 0110

5: 0101

Complement and increment 5: -5 = 1011

Add 6 and -5:

0110

__+ 1011__

1 0001

Again, we had an overflow to the fifth bit, but we got the right answer (6 - 5 = 1). What happens if we take 5 - 6?

5: 0101

6: 0110

Complement and increment 6: -6 = 1010

0101

__+ 1010__

0 1111

We get -1 and there's no overflow to the fifth bit! We thus see that the fifth bit (or, in general, the bit one to the left of the most significant bit in the numbers with which we're working) = 1 if the minuend is bigger than the subtrahend, and that bit = 0 if the subtrahend is bigger than the minuend. This is more information rich than sign-magnitude binary, and takes less puzzling to do subtraction. That is why, inside computers, two's complement representation is nearly universal.