Binary Substraction
§Binary Substraction :
Binary Substraction (base 2) works same as decimal Substraction (base 10),a process of Substracting binary numbers
Rules :
| Result | Borrow | ||||
|---|---|---|---|---|---|
| 1 | - | 0 | = | 1 | |
| 1 | - | 1 | = | 0 | |
| 0 | - | 0 | = | 0 | |
| 0 | - | 1 | = | 1 | 1 (Borrow) |
Steps : 1010 - 101 =?
1.First consider 1's column and substract the one's column (0-1) and it gives 1 ,as per rules of Substraction need to borrow 1 from the 10's place .
2.After borrowing 1 from the 10's column, the value 1 in the 10's column is changed into the value of 0.
//Binary Substraction of 1010 - 101
➊ //0-1 = 1Borrowed 1 from left.
1 0 ̷1̷ 0
- 1 0 1
--------------
1
3.Now substract the values in 10;s places (0-0) = 0 .
//0-0 = 0
➊ //Borrow
1 0 ̷1̷ 0
- 1 0 1
--------------
0 1
4.Now substract the 100's place (0-1) =1 , and borrow 1 from the 1000's place it becomes (1-1) =0.
//0-1 =1 (Borrow 1 from left)
➊ ➊ //Borrow
̷1̷ 0 ̷1̷ 0
- 1 0 1
--------------
0 1 0 1
Answer is 01012 = 510
We can substract negative binary numbers using two ways :
- Binary Substraction using 2's Complement
- Binary Substraction using 1's Complement
Binary Addition using 2's Complement
§Binary Addition using 2's Complement :
we all know how to add two positive binary numbers , but with the 1's complement we can even add two negative binary numbers and one negative with positive.
- Postive + Negative, when positive is greater
- Positive + Negative , when Negative Number is greater
- When Two Negative Numbers
§positive + Negative , when positive is greater
Steps:
1.Find the 1's complement of Negative number , add the positive number and the 1's Complement of Negative number,
2.Then ,we again add the end-around carry of the sum to the result to get the final answer .
Ex: add 1010 to (-1001)
Note: 10102 = 1010 and 10012 = 910 (-9)
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
1 1 //carryOvers
1 0 1 0
+ 0 1 1 0
1 //1 is end-around carry
-------------
0 0 0 0
Now we add end-around carry (1) to the rest of the number which is 0000 .
//0+1=1 (No carryOver,as per Binary Addition Rules)
0 0 0 0 // addition value of 1010 + 0110
+ 1 //end around carry
-------------
0 0 0 1
Answer is 0001 which is 1 i.e., 10 -9 = 1.
§positive + Negative , when Negative Number is greater
Steps:
1.Find the 1's complement of Negative number , add the positive number and the 1's Complement of Negative number,
2.Now in this case, there is no end-around carry ,so final answer is obtained by taking the 1's complement of resultant value.
Ex: add 0111 and (-1000)
Note: 01112 = 710 and 10002 = 810(-8)
Now add 1's complement and postive binary number
//1+1+1 = 1 (1 carryOver,as per Binary Addition Rules)
1 1 1 //carryOvers
0 1 1 1
+ 0 1 1 1
-------------
1 1 1 0
Now find the 1's Complement of resultant 1110 is 0001
Answer is 0001 = 1 i.e., 7-8 = -1.
Here resultant value is 0000 1110 ,when we do 1's complement of it ,we get 1111 0001 .Here MSB is 1 it means Negative number
§When Two Negative Numbers
1.In this case, we represent both the numbers in the 5-bit register by attaching required number of zeros to the left .Then we find 1's complement of both the number & add the values. 2.The End-around carry will be again added to the rest of the number Note: in this case, we will always get a carryOver digit after adding, the 1's complement is to be found for the resultant number. 3.That value with a negative sign will be answer.
Ex: add -1010 & -0101
Note: 10102 = 1010(-10) and 01012 = 510(-5)
Now find 1's Complement of both which we get 10101 & 11010
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
1 0 1 0 1
+ 1 1 0 1 0
1 //end-around carryover
----------------
0 1 1 1 1
Now we got resultant = 01111 and endaround carry is 1 . Add endaround carry to resultant
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
➀ ➀ ➊ //carryOvers
0 1 1 1 1
+ 1
❶ //end-around carryover
----------------
1 0 0 0 0
Now we have to find 1's complement of 100000 which is 01111
Hence -01111 is final answer and -011112 = ( -15 )10
Binary Addition using 1's Complement
§Binary Addition using 1's Complement :
we all know how to add two positive binary numbers , but with the 1's complement we can even add two negative binary numbers and one negative with positive.
- Postive + Negative, when positive is greater
- Positive + Negative , when Negative Number is greater
- When Two Negative Numbers
§positive + Negative , when positive is greater
Steps:
1.Find the 1's complement of Negative number , add the positive number and the 1's Complement of Negative number,
2.Then ,we again add the end-around carry of the sum to the result to get the final answer .
Ex: add 1010 to (-1001)
Note: 10102 = 1010 and 10012 = 910 (-9)
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
1 1 //carryOvers
1 0 1 0
+ 0 1 1 0
1 //1 is end-around carry
-------------
0 0 0 0
Now we add end-around carry (1) to the rest of the number which is 0000 .
//0+1=1 (No carryOver,as per Binary Addition Rules)
0 0 0 0 // addition value of 1010 + 0110
+ 1 //end around carry
-------------
0 0 0 1
Answer is 0001 which is 1 i.e., 10 -9 = 1.
§positive + Negative , when Negative Number is greater
Steps:
1.Find the 1's complement of Negative number , add the positive number and the 1's Complement of Negative number,
2.Now in this case, there is no end-around carry ,so final answer is obtained by taking the 1's complement of resultant value.
Ex: add 0111 and (-1000)
Note: 01112 = 710 and 10002 = 810(-8)
Now add 1's complement and postive binary number
//1+1+1 = 1 (1 carryOver,as per Binary Addition Rules)
1 1 1 //carryOvers
0 1 1 1
+ 0 1 1 1
-------------
1 1 1 0
Now find the 1's Complement of resultant 1110 is 0001
Answer is 0001 = 1 i.e., 7-8 = -1.
Here resultant value is 0000 1110 ,when we do 1's complement of it ,we get 1111 0001 .Here MSB is 1 it means Negative number
§When Two Negative Numbers
1.In this case, we represent both the numbers in the 5-bit register by attaching required number of zeros to the left .Then we find 1's complement of both the number & add the values. 2.The End-around carry will be again added to the rest of the number Note: in this case, we will always get a carryOver digit after adding, the 1's complement is to be found for the resultant number. 3.That value with a negative sign will be answer.
Ex: add -1010 & -0101
Note: 10102 = 1010(-10) and 01012 = 510(-5)
Now find 1's Complement of both which we get 10101 & 11010
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
1 0 1 0 1
+ 1 1 0 1 0
1 //end-around carryover
----------------
0 1 1 1 1
Now we got resultant = 01111 and endaround carry is 1 . Add endaround carry to resultant
//1+1 = 0 (1 carryOver,as per Binary Addition Rules)
➀ ➀ ➊ //carryOvers
0 1 1 1 1
+ 1
❶ //end-around carryover
----------------
1 0 0 0 0
Now we have to find 1's complement of 100000 which is 01111
Hence -01111 is final answer and -011112 = ( -15 )10