Let A be an n-bit signed binary number in one’s complement form.
The most significant bit represents the
sign. If it is a “0” the number is
positive and if it is a “1” the number is negative. The remaining (n-1) bits represent the
magnitude, but not necessarily as a simple weighted number. Consider the following one’s complement
numbers and their decimal equivalents:
0111111 |
|
+ 63 |
0000110 |
--> |
+
6 |
0000000 |
--> |
+ 0 |
1111111 |
--> |
+ 0 |
1111001 |
--> |
- 6 |
1000000 |
--> |
- 63 |
There are two representations of “0”, namely 000.....0 and
111.....1.
From these illustrations we observe
If the most significant bit (MSD) is zero the remaining (n-1) bits
directly indicate the magnitude.
If the MSD is 1, the magnitude of the number is obtained by taking the
complement of all the remaining (n-1) bits.
For example consider one’s complement
representation of -6 as given above.
Leaving the first bit ‘1’ for the sign, the remaining bits 111001 do
not directly represent the magnitude of the number -6.
Take the complement of 111001, which becomes 000110 to determine the
magnitude.
In the example shown above a 7-bit number can cover the range from +63
to -63. In general an n-bit number has a
range from +(2n-1 - 1) to -(2n-1 - 1) with two
representations for zero.
The representation also suggests that if A is an integer in one’s
complement form, then
one’s complement of A = -A
One’s complement of a number is obtained
by merely complementing all the digits.
This relationship can be extended to
fractions as well.
For example if A = 0.101 (+0.625)10, then the one’s
complement of A is 1.010, which is one’s complement representation of (-0.625)10. Similarly consider the case of a mixed
number.
A = 010011.0101 (+19.3125)10
One’s
complement of A = 101100.1010 (-
19.3125)10
This relationship can be used to determine one’s complement
representation of negative decimal numbers.
Example 1: What is one’s complement binary representation of decimal number
-75?
Decimal number 75 requires 7 bits to represent its magnitude in the
binary form. One additional bit is
needed to represent the sign. Therefore,
one’s complement representation of 75 =
01001011 one’s complement representation of -75 = 10110100
Lesson meta keywords and meta description:
Write a public review