**⌚ September 22, 2014**

We can subtract one number from another in binary to obtain a binary difference. Numbers are subtracted in the same way as in decimal, though borrowing requires some explanation.

There is more than one way to perform binary subtraction, and in this lesson, we will focus on the longhand method in order to understand the process.

## Subtraction Order

Unlike binary addition, order matters in subtraction. The number we are subtracting from (the top number) is called the **minuend**, and the number subtracting (the bottom number) is called the **subtrahend**. The result of subtraction is called the **difference**.

10011b <---- Minuend - 11b <---- Subtrahend ---------- 10000b <---- Difference

## Binary Subtraction Rules

As a shortcut, there are four subtraction combinations possible. Learning these combinations makes binary subtraction a simple process.

Rules: 1 - 1 = 0 0 - 0 = 0 1 - 0 = 1 0 - 1 = 1

For those familiar with logic gates, the four possible combinations are the same as exclusive OR (XOR). When we subtract in binary, we are really applying the XOR operation on two bits in the same column to obtain the result for that column. However, be aware now that processing columns individually without accounting for significant bits during a borrow and carry operation does not always produce a correct difference (explained later).

Rule #4 requires explanation because, normally, we cannot subtract something from nothing. How does 0 – 1 = 1? What we see here is the end result of a borrow process. There are some steps not shown, so let us subtract 1b from 10b (2d – 1d = 1d) to see how this works. Assume binary values.

10b - 1b -------

We subtract from right to left, so we begin in the least significant column. This means 0 – 1. We cannot subtract 1 from nothing, so we must borrow a 1 from the next significant column on the left. However, the next column occupies the twos place, and it actually consists of two 1s. To borrow, we must “split up the 2” into two 1s (because 10b = 1b + 1b) and place both 1s in the ones column to produce a column of three ones. Remember, 1 + 1 = 10b in binary, so if we undo that operation, 10b = 1b + 1b. Cross out the 1 of 10b after borrowing the 1 from the next significant place.

1 1 00 - 1 -------

We now have a column of three 1s. Now, subtract 1 from 1 in this column. Which 1s are chosen does not matter.

1 0 00 - 0 -------

This leaves one 1 remaining in the column, so we bring this 1 down and record it in the column as part of the difference.

0 00 - 0 ------- 1

Further subtraction is not possible, so the process is finished. This is why 0 – 1 results in 1. No matter the place value, whenever we borrow from the next significant column containing a 1 in binary, we are always borrowing a 2 (10b) and splitting the 2 into two 1s. From the borrow operation, we always record two additional 1s in the needed column.

**Example: 101b – 10b**

101b - 10b ----------

1 <---+--- Borrow from the next significant column. Record two 1s 1 <---+ 001b - 10b ----------

0 <---+--- Subtract 1 - 1. Which two 1s to subtract does not matter. 0 <---+ 001b <--- One 1 remains from the column of three 1s. Record this 1. - 10b ---------- 11b

Before we can borrow from the next significant digit, there must first be a digit to borrow from. This means the minuend must be the larger number. If not, then the minuend and subtrahend placement is incorrect. Reverse the order, and the subtraction will succeed.

**Incorrect:**

0011b <--- Smaller number at top. No, no. - 1001b <--- Larger number on bottom. Cannot borrow at last digit. --------

**Correct:**

1001b <--- Minuend is the larger number - 0011b <--- Subtrahend is the smaller number --------

This makes sense because normal subtraction is all about subtracting a smaller value from a larger value. (Ignore signed differences for now.)

When borrowing, there will be cases of skipping multiple columns of 0s before reaching the next significant place containing a 1. Borrow and carry across all columns as in decimal.

1001 <--- Two 0s in a row - 0011 --------

Above, there is a need to borrow in the second column, but we cannot borrow from the third column because nothing is there. We must borrow from the fourth column and remove its 1, carry two 1s to the third column, borrow from the third column to the second, and then subtract in the second column. The next example will explain this in detail.

## How to Perform Binary Subtraction

### Subtract 1001b – 11b.

Align at the radix point and pad with leading zeros. Assume binary values.

1001 - 0011 -------- 0 <--- 1 - 1 = 0, so we record 0 in the ones place.

Proceed to the next significant column. We see 0 – 1.

1001 - 0011 -------- 0

1 does not subtract from 0, so we must borrow from the next significant column. Recall the rule explained above. When we borrow a 1 from a more significant column, we must carry two 1s. However, we will need to continue borrowing until we find the next significant digit containing a 1.

1001 - 0011 -------- 0

The next significant column is 0, but there is nothing to borrow here. Try the next significant column. The 1 in the fourth column is split into two 1s that are placed in the third column. (10b = 1b + 1b)

1 1 0001 - 0011 -------- 0

We borrow one carried 1 from the third column by splitting it into two 1s and placing both of the 1s in the second column. Cross out the borrowed 1 in the third column while leaving the other.

01 11 0001 - 0011 -------- 0

There are three 1s in the second column, so now we can subtract 1 – 1.

01 11 0001 - 0011 -------- 0

One 1 remains in the second column, and it is this 1 that we bring down and record in the answer.

01 10 0001 - 0001 -------- 10

Proceed to the third column where the borrowed 1 awaits. Bring it down and record it in the answer.

0 00 0001 - 0001 -------- 110

Converting 110b to 6d shows that 1001b (9d) – 11b (3d) = 110b (6d).

Even though 0 – 1 = 1, it is important to keep note from which 1 bit the borrow occurred in order to change it to 0. We cannot use the rules to subtract each column by itself without regard for the more significant columns because this will yield an incorrect difference if borrowing is needed. For example:

**Incorrect:**

1001 - 0011 -------- 1010

Here, we applied the subtraction rules to each column individually from right to left. The answer is *wrong* because the bit we borrowed from remains as 1, and the 1 borrowed from was never recorded in the third column as a result of the borrow and carry operation.

This is why this process is called the longhand method. It takes time to record each step. This is good for practice in understanding, but not practical for repeated binary subtractions. A simpler method is to use the twos complement with binary addition, which we will explain in another lesson.

## Subtracting Binary Fractions

The subtraction process is the same for binary fractions. Align both numbers by the radix point and pad with leading and trailing 0s to avoid confusion and mistakes.

### Subtract 1.1b – 0.1b

1.1b - 0.1b -------

We line up 1.1b and .1b by the radix point. This is important in binary just as it is important in decimal. We also pad the .1b with a leading 0 to help avoid errors. Next, we subtract as before starting at the least significant bit (rightmost bit).

1.1b - 0.1b ------- 1.0b

1.1b – 0.1b = 1.0b. To verify, convert all values to decimal and perform the same subtraction in decimal.

1.1b (1.5d) - 0.1b (0.5d) -------------- 1.0b (1.0d)

### Subtract 1001.101b – 10.11b

Line up by the radix point and pad with 0s.

1001.101b - 0010.110b ------------

Subtract as usual. Note the carry in the fractional place. Borrow and carry across the radix point as if the radix point did not exist.

1001.101b - 0010.110b ------------ 1

In the second column from the right (the 2^-2 column), we must subtract 0 – 1. Borrow from the 2^-1 column and record two 1s in the 2^-2 column.

1 1 1001.001b - 0010.110b ------------ 1

Subtract the two carried 1s from each other, and record the remaining 1.

0 0 1001.001b - 0010.110b ------------ 11

In the 2^-1 column, we must subtract 0 – 1 again, so we borrow across the radix point. The process is the same. Borrow from the next significant place, and split the 2 into two 1s. Record the two 1s in the 2^-1 column.

1 1 1000.001b - 0010.110b ------------ 11

Subtract and record the remaining 1.

0 0 1000.001b - 0010.110b ------------ .111

Complete the rest of the subtraction as usual. Remember to record the radix point in the difference.

10 00 0000.001b - 0010.110b ------------ 110.111b

The difference is 110.111b. A few steps are not shown in order to provide practice. To confirm, convert the original problem into decimal and subtract.

1001.101b 9.625d (9 + .5 + .125 = 9.625d) - 0010.110b 2.750d (2 + .5 + .25 = 2.75d) ---------------------- 110.111b = 6.875d (9.875 - 2.75 = 7.125d) (110.111b = 6 + .5 + .25 + .125 = 6.875d)

The key to obtaining a correct difference lies in the borrow and carry process. Pay careful attention to ensure that bits carried across multiple places are accounted for and subtracted properly in each column. Remember, we can borrow from carry bits using the same process.

Here is a figure to help explain the borrow and carry process.

## Practice

Here are a few subtraction problems to help understand how binary subtraction operates. Complete each problem using pencil and paper. Do not use a calculator!

- 1111b – 1111b
- 111b – 11b
**10b – 1b****101b – 10b**- Convert problem 4 into decimal. Subtract and verify by converting the difference into binary.
- Which number are we subtracting
*from*: The minuend or the subtrahend? **1.1b – 0.1b**- 0.0011b – 0.0001b
- 10.01b – 0.11b and convert to decimal to verify.
**1001.101b – 10.11b**

### Answers

- 0 (Zero is zero no matter the base.)
- 100b
- 1b
- 11b
- 101b = 5d. 10b = 2d. 5 – 2 = 3d. 3d = 11b.
- The minuend, which is the larger, top number. The subtrahend is the smaller, bottom number.
- 1.0b
- 0.001b (We can omit the trailing 0, but the leading 0 helps note the radix point.)
- 1.1b. 10.01b = 2.25d. 0.11b = 0.75. 2.25 – 0.75 = 1.5d. 1.5d = 1.1b
- 110.111b