## 9s and 10s complements decimal subtraction

Subject: Computer Science

#### Overview

In computer system, subtract, add, divide and multiple is not done as arithmetic way. It is performed by the technique that is called Complement. 1s complement and 2s complement 9s complement and 10s complement

### COMPLEMENT

In a computer system, subtraction is not performed directly as arithmetic subtraction. It is performed by the technique called complement. It is the process of repeated addition.

• There are two types of complement: rs complement and (r-1)s complement.

Where 'r' is the base of a number system.

In binary number system, there are two types of complement: 1s complement and 2s complement.

Similarly, decimal number system has 9s and 10s complement.

• #### 1s Complement

1s complement of a binary number is obtained by subtracting each bit by 1. We can get 1s complement by simply replacing 1 by 0 and 0 by 1.

Example: 1s complement of 1011 = 0100

Subtraction of binary numbers using 1s complement

Steps are here as below:

1. Make the both numbers having the same number of bits.
2. Determine the 1s complement of the number to be subtracted(subtrahend).
3. Add the 1s complement to the given number from which we subtract (minuend).
4. If there exists any additional bit (carry) in the result after addition, remove and add it to the result else (i.e. if there exists no any carry)
5. Determine the 1s complement of the result and prefix by a negative sign to get the final result.

Example: Subtract 1110000 from 1100000 • #### 2s complement

The 2s complement of a binary number is obtained by adding binary 1 to the 1s complement of the number. Subtraction using 2s complement:

Steps are here as below:

1. Make the both numbers having the same number of bits.
2. Determine the 2s complement of the number to be subtracted (subtrahend).
3. Add the 2s complement to the given number from which we subtract (minuend).
4. If there exits no carry determine the 2s complement of the result and prefix by a negative sign to get a final result.

Example:Subtract 1110000 from 1100000 • #### 9s Complement and 10s Complement

The 9s complement of decimal number can be obtained by subtracting each digit of the number from 9.

For example, the 9s complement of 3 is 6 (9-3=6), and 234 is 765 (999-234 =765).

The 10s complement of decimal number can be obtained by adding 1 to the least significant digit of 9s complement of that number. For example, 10s complement of 3 is 7 (9-3=6+1=7), and 123 is 877.

Subtraction of decimal number using 9s complement

Here are the steps are given below:

1. Make the both numbers having the same number of digits.
2. Determine the 9s complement of the number from which we subtracted (subtrahend).
3. Add the 9s complement to the given number from which we subtract (minuend).
4. If there exists any additional digit (carry) in the result after addition, remove it and add it to the complement of the result and prefix by a negative sign to get the final result.

E.g. Subtract (123)10 From (345)10
9s complement of 123= (999 -123) =876
Adding the 9s complement with 345, i.e 345 + 876 = 1221

In the result, most significant digit 1 is the carryover. So add this carry over to remaining digits 221
i.e, 221 + 1 = 222
Hence, (222)10 is the required result after subtracting (123)10 from (345)10.

Subtraction using 10s complement:

Here are the steps are given below:

1. Make the both numbers having same numbers of digits.
2. Determine the 10s complement of the number to be subtracted (subtrahend).
3. Add the 10s complement to the given number from which we subtract (minuend).
4. If there existss any additional digit (carry) in the result after addition, remove it from the result and the remaining digits form the final result.
5. If there exists no any carry then determine the 10s complement of the result and prefix by the negative sign to get the final result.

Example: Subtract (123)10 from (345)10

10s Complement of 123 = (999 - 123) = 876 + 1 = 877
Adding the 10s complement with 345, i.e. 345 + 877 = 1222
In this result, most significant digit 1 is the carry over.So remove it to find the result.
Therefore, (222)10 is the required result.

### Binary Mathematics

#### 1. Binary Addition

 Rule for binary addition0+0=01+0=10+1=11+1=10 (0 with carry over 1) Example: Binary addition101101+101111000100 sum

#### 2. Binary Subtraction

 Rule for binary subtraction 1-1=01-0=10-1=1 (with borrowing 1)0-0=0 Example: Binary addition101101 minuend-10111 subtrahend10110 difference

#### 3. Binary Multiplication

 Rule for binary multiplication1*1=11*0=00*1=00*0=0 Example: Binary multiplication1011 multiplicand *1011 multiplier10111011*0000** +1011***1111001 product

#### 4. Binary Division

 Rule for binary division1/1=11/0=not defined0/1=00/0=not defined Example: Binary DivisionDivide 101011 by 110110) 101011 (111 quotient -1101001 -110111 -1101 remainder

#### Some Basic Terms Related with Number System

• MSB (Most Significant Bit)

The left most bit of a number is called MSB.

Example :

1010 = MBS

• LSB (Leas Significant Bit)

The right most bit of a number is called LSB.

Example:

1010 = LSB

BIT: Single binary number either 0 or 1

Nibble: Combination of 4 binary bits e.g. 1001

Byte: Combination of 8 binary bits e.g. 1001 0111

(Shrestha, Manandhar, and Roshan)

### Bibliography

Shrestha, Prachanda Ram, et al. Computer Essentials. Kathmandu: Asmita's Publication, 2014.

Gurung,Judha Bahadur et.al.,Computer Science-XI,Bhundipuran Prakashan,Ktm

##### Things to remember
• In a computer system, subtract, add, divide and multiple are not done as an arithmetic way it is performed by the technique that is called Complement.
• 1s complement is a binary number i.e obtained by subtracting each bit by 1.We can get 1s complement by simply replacing 1 by 0 and 0 by 1.
• 2s complement is also of a binary number i.e, obtained adding binary 1 to the 1s complement of the number.
• 9s complement is of decimal number i.e, obtained by subtracting each digit of the number from 9.
• 10s complement is also of decimal number i.e, can be obtained by adding  1 to the least significant digit of  9`s complement of that number.

• It includes every relationship which established among the people.
• There can be more than one community in a society. Community smaller than society.
• It is a network of social relationships which cannot see or touched.
• common interests and common objectives are not necessary for society.