In: Computer Science
What decimal number is represented by the binary 2’s complement 8-bit number 11100111? Show your work
In a signed binary two's complement, the first bit (the
leftmost) indicates the sign,
1 = negative, 0 = positive.
1110 0111 is the binary representation of a negative integer, on 8
bits.
* Run this step only if the number is negative *
Subtract 1 from the binary initial number:
1110 0111 - 1 = 1110 0110
* Run this step only if the number is negative *
Flip all the bits in the signed binary one's complement
representation (reverse the digits) - replace the bits set on 1
with 0s and the bits on 0 with 1s:
!(1110 0110) = 0001 1001
0001 1001(2) =
(0 × 27 + 0 × 26 + 0 × 25 + 1 × 24 + 1 × 23 + 0 × 22 + 0 × 21 + 1 ×
20)(10) =
(0 + 0 + 0 + 16 + 8 + 0 + 0 + 1)(10) =
(16 + 8 + 1)(10) =
25(10)
If needed, adjust the sign of the integer number by the first
digit (leftmost) of the signed binary:
1110 0111(2) =
-25(10)
Number 1110 0111(2) converted from signed binary two's complement representation to an integer in the decimal system (in base 10):
1110 0111(2) = -25(10)