Subject: Computer Science
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.
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 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:
Example: Subtract 1110000 from 1100000
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:
Example:Subtract 1110000 from 1100000
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:
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:
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.
Rule for binary addition0+0=01+0=10+1=11+1=10 (0 with carry over 1) | Example: Binary addition101101+101111000100 sum |
Rule for binary subtraction 1-1=01-0=10-1=1 (with borrowing 1)0-0=0 | Example: Binary addition101101 minuend-10111 subtrahend10110 difference |
Rule for binary multiplication1*1=11*0=00*1=00*0=0 | Example: Binary multiplication1011 multiplicand *1011 multiplier10111011*0000** +1011***1111001 product |
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 |
The left most bit of a number is called MSB.
Example :
1010 = MBS
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)
Shrestha, Prachanda Ram, et al. Computer Essentials. Kathmandu: Asmita's Publication, 2014.
Gurung,Judha Bahadur et.al.,Computer Science-XI,Bhundipuran Prakashan,Ktm
© 2019-20 Kullabs. All Rights Reserved.