2´s Complement Representation:
2´s complement representation is the most used representation on modern computers. This notation allows a computer to perform addition and subtraction using the same operations. Sign bit 0 and 1 represent positive and negative numbers respectively. The magnitude part represents the 2’s complement of the actual number.
Example 1:
Representation of +10 and -10:
Example 2:
-5 represented by 2’s complement, first write +5 → 0101 then take its 2’s complement.1011→ represents the -5 in terms of 2’s complement.
Properties of 2´s complement Representation:
1. 2´s complement extends the same hardware for addition and subtraction.
2. 2´s complement is a weighted system. It is the only code that assigns ‘-ve’ weight to all sign bit.
3. If a signed number in 2´s complement form is
Then its decimal equivalent will be
Example:
If is a number represented in 2´s complement form, then its decimal equivalent will be
4. With n bits the range of numbers that can be represented in 2´s complement form will be
Example:
If consider 8 bits, we can represent -128 to +127.
If consider 4 bits, we can represent -8 to +7.
5. Sign Extension in 2´s complement form:
The rule of sign extension is the same as that of in 1´s complement form. Here also sign bit is copied to all extended positions.
Example:
Representation of -7 in 8 bits (without sign extension)
Representation of -7 in 8 bits (with sign extension)
Advantages of 2´s complement representation over the signed magnitude and its complement
1. 2´s complement has only one value for zero, i.e. 2´s complement has the same representation of +0 and -0, unlike other representations.
2. 2´s complement arithmetic is faster than1´s complement arithmetic as there is no need for correction of end-around carry. (EAC)
Question:
(-13) 2’s Complement form?
Answer:
-5 represented by 2’s complement, first write +13 → 01101.
After that takes its 2’s complement .10011→ represents the -13 in terms of 2’s complement.
Question:
A number in 2’s complement form as 1010. Find the equivalent decimal.
Answer:
1010
Let another 2’s complement form 11010
11010
Important note:
If we notice 1010 and 11010 two 2’s complement forms give the same result -6.
So, it is clear that at +ve or –ve number in 2’s complement or 1’s complement form, if we replicate the MSB, then the value remains the same.
11111111010 it also gives you the same value -6.
Let +ve number (1’s or 2’s complement)
+6
↓
00110 – if you copy MSB 00000110 it same +6.
Let 1’s Complement (-ve number)
-6
First, write +6→ 0110
After 1’s Complement
-6 → 1001
So, (1001) = -6
Let copy MSB 11111001 is same -6.
Contributed by