Binary addition and subtraction —
Intro
This is a continuation of the learning binary series. Be sure to read learning binary before reading this post.
Binary addition
Lets start with basic decimal addition.
The basic values column
1000  100  10  1
Example
1  1  
1  5  9  5  
+  3  5  6  4  
_  _  _  _  
5  1  5  9 
We take the first digit and carry that. While the second digit remains below.
The digit you carried is added to the number.
5 + 4 = 9 > 9 Is less then 10 so we don’t carry over.
9 + 5 = 15 > 15 is higher then 10. We need to carry a 1 over into the 100’s column.
1 + 5 + 5 = 11 > 11 is higher then 10. We need to carry a 1 over into the 1000’s column.
1 + 1 + 3 = 5 > 5 is less then 10 so we don’t carry over.
Answer 5159
Onto binary addition
Binary addition is the same concept. Except for your using binary numbers 1 and 0.
The five basic addition rules
0 + 0 = 0
1 + 0 = 1
10 + 0 = 10
1 + 1 = 10 > 1 + 1 = 2 > 10 = 2 in binary
10 + 1 = 11
Example
1  1  1  
1  0  1  1  
+  1  0  1  1  
_  _  _  _  _  
1  0  1  1  0 
1 + 1 = 10 > We carry the 1
1 + 1 + 1 = 10 + 1 = 11 > We carry the 1
1 + 0 = 1
1 + 1 = 10 > Since there is no more columns to carry. We put 10.
You can double check
1011 = 11
1011 = 11
11 + 11 = 22
Answer 10110 = 22
Binary subtraction
Lets start with basic decimal subtraction
Example
3  4  16  
3  

4  
−  2  3  4  9  0  
_  _  _  _  _  _  
1  0  0  7  4 
4 – 0 = 4
Borrow 1 to make 16 – 9 = 7
Borrow to make 4 – 4 = 0
Borrow to make 3 – 3 = 0
3 – 2 = 1
Answer 10074
Onto binary subtraction
The four basic subtraction rules
0 – 0 = 0
1 – 0 = 1
1 – 1 = 0
10 – 1 = 1
0  1  10  10  
1  
−  1  1  1  0  
_  _  _  _  _  _  
0  0  1  1  1 
1 – 0 = 1
Borrow 1 to make 10 – 1 = 1
Borrow 1 to make 10 – 1 = 1
Borrow 1 to make 1 – 1 = 0
Borrow 0 to make 0
You can double check
10101 = 21
1110 = 14
21 – 14 = 7
Answer 111 = 7
I hope you enjoy my tutorial on how to subtract and add binary numbers. The next guide in this series will be how to multiply and divide binary numbers.
Categorised as: Binary
If I saw this post back in October when I had to learn assembly code this would have been amazing helpful. The professor over complicated things. I am bookmarking this for future reference!
Thank you so much.