Binary Number System: Representations | |
2's-Complement Signed Binary Integer
S = 0 for non-negative numbers S = 1 for negative numbers EXAMPLE 1 What is the 32-bit 2's-complement signed binary integer representation for the decimal integer -47?
1. Solve as for an unsigned integer for the magnitude: 4710 = 10111122. Pad with zeroes to form a 32-bit number: 00000000000000000000000000 1011113. If the value was non-negative, the answer is now complete. 4. For a negative number we must next invert all the bits: 111111111111111111111111110100005. Add one to the result: 111111111111111111111111110100016. Convert to hex: 1111 1111 1111 1111 1111 1111 1101 0001 EXAMPLE 2 What is the value of the 2's-complement number represented by the hexadecimal number FFFFFF99?
1. Write out the bits: 1111 1111 1111 1111 1111 1111 1001 10012. Since the first bit is a 1 this is a negative number. We must continue. Invert all the bits. 0000 0000 0000 0000 0000 0000 0110 01103. Add 1.
0000 0000 0000 0000 0000 0000 0110 01114. Convert this result to decimal: 11001112 = 103105. Since the value is negative, the original binary number was the 2's-complement representation of the decimal number -103. |