In this tutorial, you will learn how to perform subtraction in number systems. You will learn how to subtract two numbers in the Decimal, Binary, Hexadecimal, and Octal number system along with examples.

**Contents:**

- Basic steps for Subtraction
- Decimal Subtraction
- Binary Subtraction
- Examples of Binary Subtraction
- Octal Subtraction
- Examples of Octal Subtraction
- Hexadecimal Subtraction
- Examples of Hexadecimal Subtraction

## Basic steps for Subtraction

Subtracting two numbers implies reducing the first number by one as many times as the second number. Here are the steps listed which are followed for subtraction in each number system.

- Start by subtracting the last digits as per decimal convention.
- We have the concept of taking borrow from the left digit if we have to subtract a bigger digit from a smaller one. The borrow taken is 10 (numerically equivalent to the base) as the digit on left is 10 times greater according to the positional values.
- If the smaller digit is to be subtracted from the bigger digit, no borrow is taken.
- In the case of a borrow, the left digit is reduced by 1. The equivalent value of 10 in that number system is then added to the smaller digit, and the bigger digit is subtracted from it according to the usual subtraction.
- Alternatively, the table can be referred to directly while performing subtraction.

## Decimal Subtraction

The decimal number system has 10 digits ranging from 0-9. Here is a table that shows decimal subtraction.

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |

0 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |

1 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |

2 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 |

3 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 |

4 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 |

5 | 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 |

6 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 |

7 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 |

8 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 9 |

9 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |

As shown in the table,

- Each digit is obtained by subtracting i
^{th }row and j^{th }column where i and j can vary from 0 to 9.

Digit_{ij}= digit_{rowi}– digit_{columnj} - All the digits shown in red will take a borrow of one from its left digit.
- All digits shown in red will require a borrow of 10.

Here is an example of decimal subtraction shown in the figure.

As shown in the figure,

- (83)
_{10}– (45)_{10}= (38)_{10}(A borrow is taken from the left digit and the left digit becomes 7 on reducing) - (67)
_{10}– (49)_{10}= (18)_{10}(A borrow is taken from the left digit and the left digit becomes 5 on reducing) - The arrow shows a borrow taken.

## Binary Subtraction

Binary has only two digits 0 and 1, so we have only four combinations possible for any arithmetic operation in binary. The table for subtracting two digits in binary is as follows:

A | B | Diff | Borrow |
---|---|---|---|

0 | 0 | 0 | 0 |

0 | 1 | 1 | 1 |

1 | 0 | 1 | 0 |

1 | 1 | 0 | 0 |

As shown in the table,

- An and B are the two inputs and difference and borrow are the two outputs.
- A borrow bit is generated in binary, only when we subtract 1 from 0.

## Examples of Binary Subtraction

Two examples of binary subtraction are shown in the figure.

As shown in the figure,

- (1101)
_{2}– (0110)_{2}In this,

1 – 0 = 1

0 – 1 = 1 (A borrow is taken from the left bit which gets reduced by 1)

1 – 1 – 1 = 1 (Again a borrow is required from the left digit)

1 – 1 – 0 = 0

= (0111)_{2} - (1011)
_{2}– (0110)_{2}In this,

1 – 0 = 1

1 – 1 = 0

0 – 1 = 1 (A borrow is taken from the left bit and the left bit is reduced by 1)

1 – 1 – 0 = 0

= (0101)_{2} - The arrow signifies a borrow taken from the left bit.

## Octal Subtraction

Octal numbers can have digits from 0-7. Here is a table to directly refer to for octal subtraction.

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |

0 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |

1 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 |

2 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 |

3 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 |

4 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 |

5 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 |

6 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 |

7 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |

As shown in the table,

- Each digit is obtained by subtracting i
^{th }row and j^{th }column where i and j can vary from 0 to 7.

Digit_{ij}= digit_{rowi}– digit_{columnj} - All the digits shown in red will take a borrow of one from its left digit.

Subtraction in octal makes use of decimal subtraction. Subtraction can be done in the following steps: –

- We normally subtract the digits as per the rule if we get the upper digit > than lower digit.
- If we have to subtract a bigger digit from a smaller digit, we take 10 as borrow from the left digit and reduce the left digit by 1.
- We then add 8 to the lower digit as (10 in octal is equivalent to 8), and then we decimally subtract the higher digit from this number.

## Examples of Octal Subtraction

Here some octal subtraction examples are shown in the figure.

As shown in the figure,

- (326)
_{8}– (163)_{8}In this,

6 – 3 = 3 (3 < 6, so no borrow needed.)

2 – 6 = 2 + 8 – 6 = 4 (2 < 6 so, we take 10 as borrow from left digit and add 8, and then subtract 6)

3 – 1 – 1 = 2 – 1 (The borrow taken from 3 reduces it to 2 and then we subtract 1 from it)

= 1

= (143)_{8} - (754)
_{8}– (236)_{8}In this,

4 – 6 = 4 + 8 – 6 (4 < 6 so we take 10 as borrow from left and add 8 and then subtract 6)

= 6

5 – 1 – 3 = 4 – 3 (The borrow taken is subtracted from 5 reducing it to 4)

= 1

7 – 2 = 5 (7 > 2 so no borrow is needed)

= (516)_{8}

## Hexadecimal Subtraction

Hexadecimal numbers can have digits ranging from 0-15(F). The following table can be directly referred to while doing hexadecimal subtraction.

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | |

0 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |

1 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |

2 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 |

3 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 |

4 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 |

5 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 | 6 |

6 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 | 7 |

7 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 | 8 |

8 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A | 9 |

9 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B | A |

A | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C | B |

B | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D | C |

C | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E | D |

D | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F | E |

E | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | F |

F | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |

As shown in the table,

- Each digit is obtained by subtracting i
^{th }row and j^{th }column where i and j can vary from 0 to 15.

Digit_{ij}= digit_{rowi}– digit_{columnj} - All the digits shown in red will take a borrow of one from its left digit.

To subtract two hexadecimal numbers, we do the following: –

- We subtract the hexadecimal digits as we would in decimal, taking the values of (A-F) as 10-15 respectively.
- If we get to subtract a bigger digit from a smaller one, we take a borrow of 10 from the left digit, thus its value reduces by 1.
- We add 16 to the smaller digit, as a borrow of 10 in hexadecimal means 16. After adding 16, we perform decimal subtraction again and write down the result’s corresponding hexadecimal digit as the difference.

## Examples of Hexadecimal Subtraction

Here are some hexadecimal subtraction examples shown by the figure.

As shown in the figure,

- (D91)
_{16}– (5B6)_{16}, In this,

1 – 6 = 1 + 16 – 6 (1 < 6, therefore we take a borrow, and 1 becomes 17 on adding 16)

= B (11)

9 – 1 – B = 8 + 16 – B (Reducing 9, it becomes 8. and 8 < B, so we again take borrow and add 16, and then subtract B (11) from it)

= D (13)

D (13) – 1 – 5 = 7 (D is reduced by 1 due to borrow)

= (7DB)_{16} - (3A4)
_{16}– (2F5)_{16}, In this

4 – 5 = 4 + 16 – 5 (4 < 5, therefore we take a borrow, and 4 becomes 20 on adding 16)

= 15 (F)

A – 1 – 15 = 9 + 16–15 (Reducing A, it becomes 9. To subtract 15 from it, a borrow is needed so we add 16 to 9)

= 10 (A)

3 –1 – 2 = 0 (3 is reduced to 2 due to borrow taken from it)

= (0AF)_{16}

## Key Points to Remember

These are the key points to remember in “Arithmetic Subtraction”.

- Subtraction is done starting from the last digits.
- While performing subtraction, if we have to subtract a bigger number from a smaller one, we take a borrow of 10 from the left bit, which gets reduced by 1.
- 10 is the borrow taken in each system as the digit on left is 10 times bigger. 10 represents the base in each system.
- In the binary number system, a borrow is generated only when 1 is subtracted from 0.
- The borrow taken is numerically 2, 8, 10, and 16 in binary, octal, decimal, and hexadecimal number system respectively. This borrow gets added to the smaller digit and then subtraction can be done.
- To subtract numbers in hexadecimal, the values of A-F are replaced with 10-15 respectively.

**If you find any mistake above, kindly email to [email protected]**