Dark Mode
Image

COA_Misc

Difference between 1's complement Representation and 2's complement Representation

To understand the 1's complement and 2's complement, we should know about the complements.

Complements

In order to perform the logical manipulation and to simplify the subtraction operation, the digital systems generally use complements. The binary number system contains two types of complements, i.e., 1's complement and 2's complement. Now we will describe each complement individually. After that, we will describe the difference between them.

1's Complement

The binary numbers can be easily converted into the 1's complement with the help of a simple algorithm. According to this algorithm, if we toggle or invert all bits of a binary number, the generated binary number will become the 1's complement of that binary number. That means we have to transform 1 bit into the 0 bit and 0 bit into the 1 bit in the 1's complement. N' is used to indicate the 1's complement of a number.

Example: Here, we will assume that the number is stored with the help of 4 bits.

  1. 1's complement of binary number 5 (0101) is binary number 10 (1010)  
  2. 1's complement of binary number 13 (1101) is binary number 2 (0010)      

There is another way to find the 1's complement of a number. We can use a formula to find it, which is described as follows:

N' = (2n - 1) - N

Where

N' is used to show the -N in 1's complement notation

N is used to show the positive integer

n is used to show the number of bits per word

For example:

Suppose we have 8 bit word, and N = 6. Now the 1's complement of N is described as follows:

N' = (28 - 1) - 6
    = 249
    = (11111001)2

With the help of this formula, we can convert the given number into the 1's complement.

2's Complement

The binary numbers can also be easily converted into the 2's complement with the help of a very simple algorithm. According to this algorithm, we can get the 2's complement of a binary number by first inverting the given number. After that, we have to add 1into the LSB (least significant bit). That means we have to first perform 1's complement of a number, and then we have to add 1 into that number to get the 2's complement. N* is used to show the 2's complement of a number.

Example: Here, we will assume that the number is stored with the help of 4 bits.

  1. 2's complement of binary number 5 (0101) is binary number 11 (1011)  
  2. 1's complement of binary number 13 (1101) is binary number 3 (0011)      

There is another way to find the 2's complement of a number. We can use a formula to find it, which is described as follows:

N* = 2n - N

Where

N* is used to show the -N in 1's complement notation

N is used to show the positive integer

n is used to show the number of bits per word

For example:

Suppose we have 8 bit word, and N = 6. Now the 1's complement of N is described as follows:

N* = 28 - 6
     = 250
     = (11111010)2

With the help of this formula, we can convert the given number into the 2's complement.

Difference between 1's Complement and 2's Complement

There are various differences between 1's complement and 2's complement. We are going to describe them with the help of different parameters, which are described as follows:

Parameters 1's complement representation 2's complement representation
Process of Generation We can get the 1's complement of a given binary number by toggling or inverting all bits of that number. We can get the 2's complement of a given binary number by first doing 1's complement of number and then adding 1 into that number.
Example The 1's complement of binary number 9 (1001) is 6 (0110). The 2's complement of binary number 9(1001) will be got by doing 1's complement of that number which is 6 (0110), and then adding 1 into it, which means 7 (0111). So the 2's complement of 9 (1001) is 7 (0111).
Logic Gates Used The implementation of 1's complement is very simple. For every bit of input, it basically uses the NOT gate. For every bit of input, the 2's complement basically uses the BOT gate and a full adder.
Number Representation If we want to represent the sign binary number, we can use the 1's. If we have a number 0, then it will not be possible to use it in the form of ambiguous representation. If we want to represent the sign binary number, we can also use the 2's. If we have a number 0, then it will possible to use it as an unambiguous representation of all given numbers.
K-bits Register If there is a k-bit register, the 1's complement will use -(2(k-1) -1) to store the lowest negative number, and (2(k-1) -1) to store the largest positive number. If there is a k-bit register, the 2's complement will use -(2(k-1)) to store the lowest negative number and (2(k-1) -1) to store the largest positive number.
Representation of 0 There are two ways to represent the number 0 in 1's complement, i.e., +0 and -0. The plus 0 will be represented as 00000000, which is positive zero (+0) in an 8-bit register, and for negative zero (-0), it will be represented as 11111111 in an 8-bit register. There is only one way to represent the number 0 in 2's complement for both +0 and -0. Both minus 0 or plus 0 can be represented as 0000000 (+0) in an 8-bit register because if we add 1 to 11111111 (-1), we will get 00000000 (+0), which is the same as positive zero. That's why the number 0 is always considered as a positive in the 2's complement. This is also the reason we generally use 2's complement.
Sign Extension In the 1's complement, sign extension is used to convert the given sign into another sign for any signed integer. The working of sign extension in 2's complement and in 1's complement is the same. Here it also converts a given sign into another sign for any signed integer.
End-Around Carry-Bit If we are performing an arithmetic operation (addition) with the help of 1's complement, in this case, we will first perform binary addition. After that, we will add the end-around carry bit. If we are performing an arithmetic operation (addition) with the help of 2's complement, in this case, an addition of end-around-carry-bit will not occur because 2's complement contains a single value for zero. The 2's complement ignores this type of addition.
Ease of operation The 1's complement always requires the addition of end-around-carry-bit. That's why the 1's complement arithmetic operation is difficult as compared to the 2's complement arithmetic operation. The 2's complement does not require the addition of end-around-carry-bit. That's why the 2's complement arithmetic operation is easier as compared to the 1's complement arithmetic operation.

Comment / Reply From