Complement In Binary Number System:
This post is in continuation of conversion of binary numbers into decimal numbers. The difference is these numbers are negative numbers. Before starting this article you should know how to convert a binary number into decimal number. Here is my article on binary numbers conversion. And the second thing you should know is the complement system, 1’s complement and 2’s complement. Here is my detailed article on representation of numbers.
Key Questions:
- Evaluation of Complement Numbers in binary number system using 1’s complement
- Evaluation of Complement Numbers in binary number system using 2’s can complement
Evaluation of Complement Numbers In Binary Numbers Using 1’s Complement:
There are few steps to follow
- First look at MSB, either a positive number or a negative number
- If the number is positive (MSB=0) then the conversion technique remains same
- If the number is negative (MSB=1) then you have to add (+1) while calculating sum of weights
Example#01:00111101)2
MSB=0; Number is positive.
00111101)2=(0*27)+(0*26)+(1*25)+(1*24)+(1*23)+(1*22)+(0*21)+(1*20)
=(0*128)+(0*64)+(1*32)+(1*16)+(1*8)+(1*4)+(0*2)+(1*1)
=0+0+32+16+8+4+0+1
=61
Lets verify
Take 1’s complement of this number 00111101, which is given below:
1’s complement=11000010)2
MSB=1; Number is negative. MSB shows both sign and magnitude of the number. We add (+1) also.
11000010)2=(-1*27)+(1*26)+(0*25)+(0*24)+(0*23)+(0*22)+(1*21)+(0*20)+1
=(-1*128)+(1*64)+(0*32)+(0*16)+(0*8)+(0*4)+(1*2)+(0*1)+1
= -128+64+2+1
=-61
00111101)2=+61)10
11000010)2=-61)10
Example#02:10110011)2
This time we have a negative number. MSB=1
10110011)2=(-1*27)+(0*26)+(1*25)+(1*24)+(0*23)+(0*22)+(1*21)+(1*20)+1
=(-1*128)+(0*64)+(1*32)+(1*16)+(0*8)+(0*4)+(1*2)+(1*1)+1
=-128+32+16+2+1+1
=-76
Lets verify
1’s complement of this number 10110011)2 which is given below:
1’s complement = 01001100)2
01001100)2=(0*27)+(1*26)+(0*25)+(0*24)+(1*23)+(1*22)+(0*21)+(0*20)
=(0*128)+(1*64)+(0*32)+(0*16)+(1*8)+(1*4)+(0*2)+(0*1)
=64+8+4
=76
10110011)2 = -76)10
01001100)2 = +76)10
Evaluation of Complement Numbers In Binary Numbers Using 2’s Complement:
The following steps to follow:
- First look at MSB, either a positive number or a negative number
- If number is positive (MSB=0), the conversion technique remains the same
- If number is negative you don't need to add (+1) as you did previously
Example#01:01110101)2
MSB=0; Number is positive
01110101)2=(0*27)+(1*26)+(1*25)+(1*24)+(0*23)+(1*22)+(0*21)+(1*20)
=(0*128)+(1*64)+(1*32)+(1*16)+(0*8)+(1*4)+(0*2)+(1*1)
=64+32+16+4+1
=117
Lets verify
Take 2’s complement of this number 01110101 which is given below
1’s complement = 10001010)2
2’s complement = 10001011)2
MSB=1; Number is negative. MSB shows both sign and magnitude of the number.
10001011)2=(-1*27)+(0*26)+(0*25)+(0*24)+(1*23)+(0*22)+(1*21)+(1*20)
=(-1*128)+(0*64)+(0*32)+(0*16)+(1*8)+(0*4)+(1*2)+(1*1)
=-128+8+2+1
=-117
01110101)2=117)10
10001011)2=-117)10
Example#02: 10011100)2
This time we have a negative number. MSB=1
10011100)2=(-1*27)+(0*26)+(0*25)+(1*24)+(1*23)+(1*22)+(0*21)+(0*20)
=(-1*128)+(0*64)+(0*32)+(1*16)+(1*8)+(1*4)+(0*2)+(0*1)
= -128+16+8+4
=-100
1’s complement = 01100011)2
2’s complement = 01100100)2
Conversion of this number 01100100)2
01100100)2=(0*27)+(1*26)+(1*25)+(0*24)+(0*23)+(1*22)+(0*21)+(0*20)
=(0*128)+(1*64)+(1*32)+(0*16)+(0*8)+(1*4)+(0*2)+(0*1)
=64+32+4
=100
10011100)2 = -100)10
01100100)2 = 100)10
Recommended Books:
My favorite books by my favorite authors. You can get all digital electronics concepts in these book. loads of examples, illustrations, exercises, applications. This book is very easy to understand for beginner to intermediate level.