In: Electrical Engineering
The standard method of representing negative numbers in the binary system is with 2's complement notation. What are the advantages and disadvantages of using this method to represent negative numbers?
Advantages-
1. 2s complement representation of signed integer is easier to manipulate in hardware (simpler and less expensive). First we just complement all the bits (also called as 1s complement) and then add 1 to the resulting 1s complement.
2. The programmer doesn't have to teach the computer to subtract by borrowing. Instead, it can complement and add.
3. In 1s complement there are two representations of zero (positive and negative zero) whereas, in 2s complement there's only one this is one of the major advantages of using 2s complement notation.
4. It is easier to determine the sign of a 2s complement number. If it begins with 0 it is positive if it begins with 1 it is negative.
Disadvantages-
1. 2s complement takes slightly longer to form negative of a number, whereas 1s complement is quicker.
2. 2s complement has an asymmetrical range, so the largest number causes overflow if you try to make it positive.