Note on 9`s and 10`s complements decimal subtraction

  • Note
  • Things to remember

www.dokuwiki.matyas.bplaced.net
Fig: Complement
www.dokuwiki.matyas.bplaced.net

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: r`s 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: 1`s complement and 2`s complement.

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

  • 1`s Complement

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

Example: 1`s complement of 1011 = 0100

Subtraction of binary numbers using 1`s complement

Steps are here as below:

  1. Make the both numbers having the same number of bits.
  2. Determine the 1`s complement of the number to be subtracted(subtrahend).
  3. Add the 1`s 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 1`s complement of the result and prefix by a negative sign to get the final result.

Example: Subtract 1110000 from 1100000

.

  • 2`s complement

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

Subtraction using 2`s complement:

Steps are here as below:

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

Example:Subtract 1110000 from 1100000

.

  • 9`s Complement and 10`s Complement

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

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

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

Subtraction of decimal number using 9`s complement

Here are the steps are given below:

  1. Make the both numbers having the same number of digits.
  2. Determine the 9`s complement of the number from which we subtracted (subtrahend).
  3. Add the 9`s 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
9`s complement of 123= (999 -123) =876
Adding the 9`s 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 10`s complement:

Here are the steps are given below:

  1. Make the both numbers having same numbers of digits.
  2. Determine the 10`s complement of the number to be subtracted (subtrahend).
  3. Add the 10`s complement to the given number from which we subtract (minuend).
  4. If there exists`s 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 10`s complement of the result and prefix by the negative sign to get the final result.


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

10`s Complement of 123 = (999 - 123) = 876 + 1 = 877
Adding the 10`s 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

  • 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.
  • 1`s complement is a binary number i.e obtained by subtracting each bit by 1.We can get 1`s complement by simply replacing 1 by 0 and 0 by 1.
  • 2`s complement is also of a binary number i.e, obtained adding binary 1 to the 1`s complement of the number.
  • 9`s complement is of decimal number i.e, obtained by subtracting each digit of the number from 9.
  • 10`s 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.

 

.

Very Short Questions

0%

DISCUSSIONS ABOUT THIS NOTE

No discussion on this note yet. Be first to comment on this note