1's & 2's Complement
1's & 2's Complement
The MSB( left most bit) of the signed binary number is called sign bit.
If it is zero( 0 ) ,the number is positive.
when it is one ( 1 ), then the number is negative.
Eg. The 4-bit signed number representation , 0 1 1 1 represents a positive number and its magnitude
is 7 . ( Left most bit MSB is 0 it represent that it is a positive number and the remaining bits 111 show its
magnitude ). The 4-bit signed number representation 1 1 1 1 represent a negative number and its
magnitude is 7 . ( 1 in left most MSB indicates that the number is negative and the other remaining bits
represent is value/magnitude )
+0 000
+1 001
+2 010
+3 011
-0 100
-1 101
-2 110
-3 111
Add +7 & -7 in sign magnitude form
+7 = 0111
-7 = 1111
0111
+ 1111
1 0110
The answer must be 0 . when addition is done the sum is different. That is why it is
least used.
1’s complement representation
In one’s complement, positive numbers (also known as non-complements) remain
unchanged .
Negative numbers however, are represented by taking the one’s complement
(inversion, negation) of the unsigned positive number. Since positive numbers
always start with a “0”, the complement will always start with a “1” to indicate a
negative number.
The one’s complement of a negative binary number is the complement of its
positive counterpart, so to take the one’s complement of a binary number, all we
need to do is change each bit. Thus the one’s complement of “1” is “0” and vice
versa, Then the one’s complement of 10010100 is simply 01101011 as all the 1’s
are changed to 0’s and the 0’s to 1’s.
3 bit representation of binary numbers
2 = 010 “ is 101
3 =011 “ is 100
0 = 000 1’s complement is 111
+0 000
+1 001
+2 010
+3 011
-3 100
-2 101
-1 110
-0 111
Range
+7 = 0111
-7 = 1000
0111
+ 1000
+7 = 0111
-7 = 1000
0111
+ 1000
Positive numbers: summing the weights of all bit positions where there are 1’s and
ignoring positions with 0’s.
Negative numbers :Assigning a negative value to the weight of the sign bit,
summing all the weights where there are 1’s and adding 1 to the result.
Eg: Determine the decimal value of the following signed binary number expressed
in 1’s complement. i) 00010111 ii) 11101000
i) 1 x 2⁴ + 1x 2² + 1x 2¹ + 1x 2⁰ = +23
In two’s complement, the positive numbers are exactly the same as before for
unsigned binary numbers. A negative number, find the 1’s complement of the
number and add 1 to it. The 2’s complement of the binary number, which when
added to its corresponding positive equivalent results in zero.
Eg: 2’s complement of -7
7 is 0111
+1
1001
2 more methods
7 in binary is 0111
2⁴= 10000
45 in binary = 00101101
0 000
+1 001
+2 010
+3 011
-4 100
-3 101
-2 110
-1 111
The main advantage of two’s complement over the previous one’s complement is
that there is no double-zero problem plus it is a lot easier to generate the two’s
complement of a signed binary number. Therefore, arithmetic operations are
relatively easier to perform when the numbers are represented in the two’s
complement format.
Decimal values of 2’s complement numbers
Decimal values of positive and negative numbers are obtained by summing the
weights in all bit positions where there are 1’s and ignoring 0’s. The weight of the
sign bit in a negative number is given a negative value.
Find the value of the following signed binary numbers expressed in 2’s
complement.
1) 0110 = 1 x 2² + 1x 2¹ = 6 or +6.
2) 10101010 = -128 + 32+8+2 = - 86
Exercise