Section 6.4
Review Questions

Converting 2's complement numbers

  1. How does 2's complement relate to 1's complement?
answer...
2's complement is almos identical to 1's complement. A number is 2's complement is the 1's complement form plus one.
  1. 87 is 1010111, after padding out to 8 bits. Find the 2's complement representation of -87.
answer...
padded out -->    01010111
invert bits       10101000
add 1                   +1
                  --------
2's complement    10101001
  1. How do 2's complement and sign-magnitude compare? Are the bit patterns similar in any way whatsoever?
answer...
not at all, totally dissimilar
  1. What is -1 in 128-bit 2's complement? (Obviously, there is a very quick shortcut!)
answer...
128 1's
  1. What is -2 in 128-bit 2's complement? (Use a similar shortcut).
answer...
127 1's followed by a 0 (1111........110)
  1. What do 2's complement and sign-magnitude have in common?
answer...
they both have a 1 in the first bit, often called the sign bit
  1. Suppose we are working with 16 bits. How many total different bit patterns are there? (This corresponds to the total number of unsigned binary numbers.)
answer...
216 = 65536
  1. Now how many signed numbers are there?
answer...
65536
  1. How many negative numbers are there? (Be careful!!! This is a trick question!)
answer...
half that, precisely 32768
  1. How many positive numbers are there? (Again, be careful! 0 is not a positive number!)
answer...
about half that, but precisely 32767 (1 less than # of negatives, because 0 uses one of the bit patterns)
  1. Suppose someone gave you a 2's complement number that was obviously negative (had a 1 in the first bit). For example, 1101010000101110101. How would you go about finding the decimal equivalent of it? State the algorithm, don't just do it for this example.
answer...
flip the bits and add 1, then convert that binary number to decimal
  1. Here's an 8-bit string of 1's and 0's. 01000001 Is this the ASCII value 'A'? Is it the decimal number 65? Is it a 2's complement number?
answer...
It could be any of these things; it depends upon how you (or the computer) interpret it at run-time.