In: Computer Science
4. Describe and explain two characteristics of 2’s Compliment Representation of integer numbers that makes it almost universally used in today’s digital computers.
The computer understands only binary as we know, and there is nothing called as negative number in the binary number system but it is absolutely necessary to represent a negative number using binary which can be done by assigning a sign bit to the number which is an extra bit required. If the sign bit is 1 then number is considered negative and if it is 0, than it will be the number will be called as positive. The main goal is to develop a technique which replaces a subtraction operation with an addition. In this way, we will be able to use the same circuit to perform both addition and subtraction. This will reduce the number of gates and, consequently, the size, power, and cost of the system.
Primary Advantage of two's complement is that the it has one value for zero while one's complement has 2 values for zero each for "Positive" zero & "Negative" zero.
Another advantage is that 2's complement doesn't require carry values.
we prefered 2's value because in this complement we do not require any carry value or extra 1.
so that the calculation part is very easy than 1's complement. so 2's complement is very preferable than 's complement.
Two's complement addition is very simple. You add numbers normally and any carry bit at the end is discarded. So they're added as follows:
0110
+1111
=10101
= 0101 (discard the carry)
But in your normal with negative number method, adding is more complicated:
0110
+ 1001
= 1111
Which is -7
For there are two zeroes for normal representation
0000 “zero"
1000 “negative zero"
Representation for different methods shown below
When you need to fill (padded bits) the register the value is being stored in. With two's complement, storing a 4-bit number in an 8-bit register is differs in larger required numbers to fill the register resulting repeating its most significant bit:
0001 (one, in four bits)
00000001 (one, in eight bits)
1110 (negative two, in four bits)
11111110 (negative two, in eight bits)
It's just a matter of looking at the sign bit of the smaller word and repeating it until it pads the width of the bigger word.
With your method you would need to clear the existing bit, which is an extra operation in addition to padding:
0001 (one, in four bits)
00000001 (one, in eight bits)
1010 (negative two, in four bits)
10000010 (negative two, in eight bits)
You still need to set those extra 4 bits in both cases, but in the normal case you need to clear the 5th bit as well. It's one tiny extra step in one of the most fundamental and common operations present in every application. Here we have to consider the MSB.It can cause a problem when numbers are not repeating.
Other characteristics of 2’s complement