Understanding One's Complement and Two's Complement Methods for Representing Negative Numbers in Binary
1's complement & 2's complement
v One's Complement or 1's complement:
This is a method to represent the Negative No. in the binary number system.
For One's complement, we need to change all '1' to '0' and '0' to '1'.
Eg., 1010 One's complement = 0101,
110 One's complement = 001 etc.
v Two's Complement or 2's complement:
This is another method to represent the Negative no. binary number system. For Two's complement, we need to add 1 in One's complement of the given number.
Eg., 1010 Two's complement = 0101
+ 1
0110
110 Two's complement = 001
+ 1
010
Q(1). Solve 12-14 in binary number system.
(12)10 = (0 0001100)2
(14)10 = (0 0001110)2
We can write this equation like 12 + (-14)
· Solve by using One's complement.
Change 00001110 to one's complement i.e. 11110001 (here 11110001 represents -14)
So, 0 0001100
1 1110001
1 1111101
Here MSB is a sign bit.
We can see Sign Bit is 1 which represents Ans. is Negative Number.
Now, we need to find the digit by One's complement. 1 1111101 👉 0 0000010 = 2
Final Answer = -2
· Solve by using Two's complement.
We can write this equation like 12 + (-14)
Change 00001110 to 2's complement i.e. 11110001 + 1 = 11110010 (here 11110010 represent -14)
So, 0 0001100
+ 1 1110010
1 1111110
Here MSB is a sign bit.
We can see Sign Bit is 1 which represents Ans. is Negative Number.
Now, we need to find the digit by Two'scomplement. 1 1111110 👉 0 0000010 = 2
Final Answer = -2
Q (2). Solve 25-20 in the binary number system.
(25)10 = (11001)2
(20)10 = (10100)2
We can write this equation 25+(-20).
· Solve by 1's complement.
10100 1's complement is 01011(i.e. -20)
So, 11001
+01011
1 00100
Here we can see the extra bit. This represents Ans. In Positive No.
In that case, Add 1 in Ans
00100 + 1 = 00101(the ans. Is 101 or 5)
· Solve by 2's complement.
10100 1's complement is 01100(i.e. -20)
So, 11001
+ 01100
100101
Here we can see the extra bit. This represents Ans. In Positive No.
In that case, just ignore the extra bit and you get the Answer.
i.e. 00101 or 5.