What is 2's Complement Number?
Why do we take 1's Complement and add 1 to it? Why don't we subtract 1 after taking 1's Complement?
Why do computers use 2's Complement?
What is 2's Complement Number?
Complementary number system is used to represent negative numbers. So, 2's Complement number system is used to represent negative numbers.
UPDATE
Q: What “2’s Complement System” says?
A: The negative equivalent of binary number is its 2’s complement. (1’s Complement +
1)
Note: 1 extra bit is required to represent the sign of a number. MSB (Most Significant Bit) is used as sign bit. If MSB is 0, then the number is positive. If MSB is 1, then the number is negative.
1’s Complement Value 2’s Complement
011 +3 011
010 +2 010
001 +1 001
000 +0 000
111 -0 000
110 -1 111
101 -2 110
100 -3 101
-4 100
How '100' (3 bits) is -4?
MSB is used as sign, if 1, its negative, if 0 it is positive.
-1 * 2^2 + 0*2^1 + 0*2^0 = -4 + 0 + 0 = -4
Similarly 101 (3 bits) is -3
-1 * 2^2 + 0*2^1 + 1*2^0 = -4 + 0 + 1 = -3
Observations:
• In 1’s complement, using 3 bits, we represented 2^3 = 8 numbers i.e from -3 to +3.
• In 1’s complement, -0 and +0 are having 2 representation. (+0 is ‘000’ and -0 is ‘111’).
But mathematically +0 and -0 are same.
• In 2’s complement, using 3 bits, we represented only 2^3 = 8 numbers i.e from -4 to +3.
• In 2’s complement, -0 and +0 are having same representation.
• Since +0 and -0 in 2’s complement is having same representation,
we are left out with one more combination which is ‘100’ = -4.
Why do we take 1's Complement and add 1 to it? Why don't we subtract 1 after taking 1's Complement?
Refer "Why Inversion and Adding One Works" topic in the below link. If I start explaining, this post will grow big. http://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
Why computer uses 2' Complement?