*This solution is for the book I am currently reading. All of my notes and solutions are available at Google Code.*

Here is my work for problem 2.22:

Show that each of the following bit vectors is a two's complement representation
of -5 by applying Equation 2.3
A. [1011]
B. [11011]
C. [111011]
Observe that the second and third bit vectors can be derived from the first by sign
extension.
Answers:
A.
1011
-(1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0)
-8 + 0 + 2 + 1
-8 + 3
-5
B.
11011
-(1 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0)
-16 + 8 + 0 + 2 + 1
-8 + 3
-5
c.
111011
-(1 * 2^5) + (1 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0)
-32 + 16 + 8 + 0 + 2 + 1
-16 + 8 + 3
-8 + 3
-5

### Like this:

Like Loading...

*Related*