Binary Subtraction Transcript

Print

The advantage of using the two's complement system to express negative binary numbers becomes apparent when we find that we can perform subtraction by addition, thus saving on the hardware needed to perform arithmetic. Let's look at the last example in the lecture, namely 12 minus 7. Because we will be adding two numbers and a potential carry, we will first need to expand our four binary addition rules so that each handles all possible combinations for three bits.

The first condition is 0 plus 0 plus 0, which results in an answer of 0 with a 0 carry. Because we will be adding two numbers and a potential carry, we first need to expand our four binary addition rules so that each handles all possible combinations for three bits.

The second is when only one of the two number values is 1, or when both number values are 0 and there is a carry. There are three possible conditions. 0 plus 0 plus 1. 0 plus 1 plus 0. And 1 plus 0 plus 0. Each of these conditions result in an answer of 1 with a 0 carry.

The third rule is when either both of the two number values is 1, or when either number value is 1 and there is a carry. There are three possible conditions. 0 plus 1 plus 1. 1 plus 0 plus 1. And 1 plus 1 plus 0. Each of these conditions result in an answer of 0 with a 1 carry.

The final rule occurs when both number values are 1 and there is a carry. The result is 1 plus 1 plus 1, which is an answer of 1 with a carry of 1.

Now let's see how we use the two's complement system to subtract 7 from 12. We begin by finding the binary values for 12 and 7. In this example, we are using 8-bit representation. So we determine the value for 12 and 7. We then convert 7 to negative 7 by taking the two's complement.

We perform the subtraction operation by adding the minuend, the number being subtracted from, in this case 12, to the two's complement of the subtrahend, the number being subtracted, in this case negative 7. Note that there is no carry into the initial operation. Beginning the addition at the least significant bit on the far left, we have 0 plus 0 plus 1 to give a sum of 1 and a carry of 0.

Moving on to the second column from the right, we have the 0 carry plus 0 plus 0 for a sum of 0 and a carry of 0. For the third set, 0 carry plus 1 plus 0 gives a sum of 1 and a carry of 0. The fourth set has 0 carry plus 1 plus 1 gives a sum of 0 and a carry of 1. The final three operations are identical, with a 1 carry plus a single 1 to give a sum of 1 and a carry of 1.

Because the final carry out is 1, we know that the answer is positive, and the magnitude is the value shown as the answer. In this case, 0 0 0 0 0 1 0 1 is equal to 5, just as we expect.

[End of Audio]