Integer Formats
Sign-Magnitude Representation (Original Binary Data)
To represent a singed decimal number in binary format, it uses the highest bit as sign bit to determine whether the binary number is negative.
stands for positive number and means negative number.
One’s Complements (Radix-1 Complements)
- Positive Number: Same as original.
- Negative Number: Inverse all bits except the sign bit of a binary number.
Two’s Complements (Radix Complements)
- Positive Number: Same as original.
- Negative Number: Plus on one’s complements.
Range of Representation
Suppose the data has bits.
Both sign-magnitude representation and one’s complements have and , so the range is
While two’s complements has only one , so the range is
In conclusion:
| Representation | Range |
|---|---|
| Sign-Magnitude Representation | |
| One’s Complements | |
| Two’s Complements |
Application of Two’s Complements
When doing subtraction, like calculating , it can be converted to calculating , where is generated by its two’s complements.
Conversion Between Sign-Magnitude Representation and Two’s Complement
If the number is positive, then the sign-magnitude representation and the two’s complement are the same.
If the number is negative, then the MSB must be . The conversion processes are the same:
Reverse all bits except the sign bit, then plus .
For example, a sign-magnitude representation is . Its two’s complement is:
Then, the two’s complement can be converted back to sign-magnitude representation with the same process:
Specially, the two’s complement of can not use this process. Since the range is , its two’s complement is the same as its sign-magnitude representation, which is .