Signed Integers (Cont.)
Two's Complement of Hexadecimal
An easy way to reverse the bits of a hexadecimal digit is to subtract the digit from 15.
Starting value
: (15,268)
10
= (3BA4)
16
3
B
A
4
Step 1
: Reverse the digits
Step 2
: Add 1 to the value from Step 1
+
0
0
0
1
Sum
2's complement notation of (-15,268)
10
is
(
)
16
Converting Signed Binary to Decimal
If the highest bit is a 0, convert the unsigned binary integer to decimal.
If the highest bit is a 1, it is stored in two's complement notation.
Starting value:
(11010100)
2
1
1
0
1
0
1
0
0
Step 1
: Reverse the bits
Step 2
: Add 1 to the value from Step 1
+
0
0
0
0
0
0
0
1
Step 3
: Form the two's complement
Step 4
: Convert to decimal
negative (
)
2
= (
)
10
Converting Signed Decimal to Binary
Convert the absolute value of the decimal integer to binary.
If the original decimal integer was negative, form the two's complement of the binary number.
Starting value:
(-38)
10
(-38)
10
Step 1
: Convert the absolute value to binary
Step 2
: Reverse the bits
Step 3
: Add 1 to the value from Step 2
+
0
0
0
0
0
0
0
1
Step 4
: Form the two's complement
2's complement notation of (-38)
10
is
(
)
2