Binary Number System: Representations

2's-Complement Signed Binary Integer

BITS


33222222222211111111110000000000
10987654321098765432109876543210
SBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB


where
S = 0 for non-negative numbers

Interpretation:

the remaining 31 bits represent the magnitude of the non-negative number.
S = 1 for negative numbers

Interpretation:

Invert all the bits 2's-complement number.
Add 1.
The resulting 32 bits represent the magnitude of the negative number.

Note: this is the same as subtracting 1 from the 2's-complement number and then inverting the bits. Click here for more background.

EXAMPLE 1

What is the 32-bit 2's-complement signed binary integer representation for the decimal integer -47?


SOLUTION

1. Solve as for an unsigned integer for the magnitude:

4710 = 1011112
2. Pad with zeroes to form a 32-bit number:
00000000000000000000000000 101111
3. If the value was non-negative, the answer is now complete.

4. For a negative number we must next invert all the bits:

11111111111111111111111111010000
5. Add one to the result:
11111111111111111111111111010001
6. Convert to hex:
1111 1111 1111 1111 1111 1111 1101 0001

FFFFFFD1


EXAMPLE 2

What is the value of the 2's-complement number represented by the hexadecimal number FFFFFF99?


SOLUTION

1. Write out the bits:

1111 1111 1111 1111 1111 1111 1001 1001
2. 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 0110
3. Add 1.

0000 0000 0000 0000 0000 0000 0110 0111
4. Convert this result to decimal:
11001112 = 10310
5. Since the value is negative, the original binary number was the 2's-complement representation of the decimal number -103.



Next Page