1's complement notation

MicrocontrollerMicroprocessor8085

This is one of the methods of representing signed integers in the computer. In this method, the most significant digit (MSD) takes on extra meaning.

  • If the MSD is a 0, we can evaluate the number just as we would interpret any normal unsigned integer.
  • If the MSD is a 1, this indicates that the number is negative.

The other bits indicate the magnitude (absolute value) of the number.

If the number is negative, then the other bits signify the 1's complement of the magnitude of the number.

Some signed decimal numbers and their equivalent in 1's complement notations are shown below, assuming a word size of 4 bits.

Signed decimal
1’s complement
   +6
   0110
   -6
   1001
   +0
   0000
   -0
   1111
   +7
   0111
   -7
   1000

Range

From the above table, it is obvious that if the word size is n bits, the range of numbers that can be represented is from -(2n-1- 1) to+(2n-1 -1). A table of word size and the range of 1's complement numbers that can be represented is shown.

Word size
Range for 1's complement numbers
4
-7 to +7
8
-127 to +127
16
-32767 to +32767
32
-2147483647 to +2147483647

Example 1

 Add the numbers (+5) and (-3) using a computer. The numbers are assumed to be represented using 4-bit 1's complement notation.

              1110 <- carry generated during addition

              0101 <- (+5) First Number

           +  1100 <-(-3) Second Number

              0001 <- (+1) Sum


The computer instead of giving the correct answer of +2 = 0010, has given the wrong answer of +1 = 0001! However, to get the correct answer the computer will have to simply add to the result the final carry that is generated, as shown in the following.

   0001

 +    1

   0010 = (+2) Result

Example 2

Add the numbers (-4) and (+2) using a computer. The numbers are assumed to be represented using 4-bit 1's complement notation.

              0010 <- carry generated during addition

              1011 <- (-4) First Number

           +  0010 <-(+2) Second Number

              1101 <- (-2) Sum


After the addition of the final array, the result remains as 1101. This is -2, which is the correct answer. In 1 101 the MSB is a 1. It means the number is negative. Then, the remaining bits do not provide the magnitude directly. To solve this problem, just consider 1's complement of 1 101. 1'scomplement of 1 101 is 0 010, which is +2. Thus, 1 101, which is 1'scomplement of 0 010 is −2.

Disadvantages

  • 1's complement notation is not very simple to understand because it is very much different from the conventional way of representing signed numbers. 

  • The other disadvantage is that there are two notations for 0 (0000 and 1111), which is very inconvenient when the computer wants to test for a 0 result.

Advantage

  • It is quite convenient for the computer to perform arithmetic. To get the correct answer after addition, the result of addition and final carry has to be added up.

Hence, 1's complement notation is also generally not used to represent signed numbers inside a computer, so the concept of 2’s complement has come.

raja
Published on 03-Jan-2019 15:56:59
Advertisements