1s Complement and 2s Complement of Binary Numbers
1s Complement and 2s Complement of Binary Numbers
1s complement and 2s complement are way of representing the signed binary numbers.
In general, the binary number can be represented in two ways.
For example, if we represent decimal 12 in 5- bit unsigned number form then (12)10 = (01100)2.
Here all 5 bit are used to represent the magnitude of the number.
In unsigned binary number representation, using n-bits, we can represent the numbers from 0
to 2n – 1. For example, using 4 -bits we can represent the number from 0 to 15 in unsigned
binary number representation.
In signed binary number representation the most significant bit (MSB) of the number is a sign
bit. For positive numbers, the sign bit is 0 and for negative number, the sign bit is 1.
There are three different ways the signed binary numbers can be represented.
Using n-bits, the range of numbers that can be represented in Sign Magnitude Representation
is from – (2n-1 – 1) to (2n -1 – 1).
For example, if we want to represent -34 in 8-bit 1’s complement form, then first write the
positive number (+34). And invert all 1s in that number by 0s and 0s by 1s in that number. The
corresponding inverted number represents the -34 in 1’s complement form. It is also called 1s
complement of the number +34.
Here is another example which shows how to represent -60 in 8-bit 1’s complement form.
Using n-bits, the range of numbers that can be represented in 1’s complement form is from –
(2n-1 – 1) to (2n -1 – 1). For example, using 4-bits, it is possible to represent integers numbers
from -7 to +7 in a 1’s complement form representation.
Similar to sign-magnitude form, there are two different representations of 0 in 1’s
complement form representation.
But the representation of the negative number is different. For example, if we want to
represent -34 in 2’s complement form then
Using n-bits, the range of number which can be represented in 2’s complement form is from –
(2n-1 ) to 2n-1 – 1. For example, using 4-bits, it is possible to represent numbers from -8 to +7.
Unlike 1’s complement and sign magnitude form, there is a unique way of representing 0 in
this 2’s complement form.