Exam 1 Review Questions - Part 2 (with Answers)

This is representative of the kinds of topics and kind of questions you may be asked on the exam. In addition to this practice exam, you should also review:

Questions

  1. In decimal, how much is a 8 in position 5 worth?
    Answer:
               8 * 10^5
             


  2. In binary, how much is a 1 in position 7 worth?
    Answer:
               1 * 2^7
    		   


  3. In hexadecimal, how much is a E in position 4 worth?
    Answer:
              14 * 16^4
    		  


  4. Convert decimal 19 into 8-bit unsigned binary. Show all work, including value of each digit.
    Answer:
    	0001 0011
    	2^4 + 2^1 + 2^0 = 16 + 2 + 1
    	


  5. Convert unsigned binary 1101 1101 into decimal. Show all work, including value of each digit.
    Answer:
    2^0 + 2^2 + 2^3 + 2^4 + 2^6 + 2^7 = 1 + 4 + 8 + 16 + 64 + 128 = 221
    


  6. Convert two's complement binary 1101 1101 into decimal. Show all work, including value of each digit.
    Answer:
    Negation:
    0010 0010
    Add one:
    0010 0011
    2^0 + 2^1 + 2^5 = 1 + 2 +32 = 35
    -35
    


  7. Consider the following binary number: 1110 0110

    Is it possible to tell if this number is in unsigned or two's complement representation? If yes, explain how. If not, explain why.

    Answer:
     It's not possible to tell. Binary numbers are not self-describing. This could be an unsigned
    number, a two's complement number, a character, or any number of other things.
    


  8. Convert decimal 2028 to 4-digit hexadecimal. Show all work, including value of each digit.
    Answer:
    A = 10
    B = 11
    C = 12
    D = 13
    E = 14
    F = 15
    2028 / 16^2 = 7, remainder 236
    236 / 16^1 = 14 (E), remainder 12
    12 / 16^0 = 12 (C), remainder 0
    0x07EC
    7 * 16^2 + 14 * 16^1 + 12 * 16^0 = 1792 + 224 + 12 = 2028
    


  9. Convert decimal -882 to 4-digit hexadecimal. Show all work, including value of each digit.
    Answer:
    882 / 2^9 = 1, remainder 370
    370 / 2^8 = 1, remainder 114
    114 / 2^7 = 0, remainder 114
    114 / 2^6 = 1, remainder 50
    50 / 2^5 = 1, remainder 18
    18 / 2^4 = 1, remainder 2
    2 / 2^3 = 0, remainder 2
    2 / 2^2 = 0, remainder 2
    2 / 2^1 = 1, remainder 0
    0 / 2^0 = 0, remainder 0
    Unsigned magnitude: 0000 0011 0111 0010
    (2^9 + 2^8 + 2^6 + 2^5 + 2^4 + 2^1 = 512 + 256 + 64 + 32 + 16 + 2 = 882)
    Flip bits: 1111 1100 1000 1101
    Add one: 1111 1100 1000 1110
    To hex: 0xFC8E 
    


  10. What is: 1111 1101 + 0100 0101? Specify if the result has a carry-out set and if the result sets the overflow bit. Show all work.
    Answer:
      1 1 1 1 1 1 0 1 0
      1 1 1 1 1 1 0 1
    + 0 1 0 0 0 1 0 1
    ------------------------
      0 1 0 0 0 0 1 0
    Carry set, overflow not set
    


  11. What is 1111 1100 + 1000 0000? Specify if the result has a carry-out set and if the result sets the overflow bit. Show all work.
    Answer:
      1 0 0 0 0 0 0 0 0
      1 1 1 1 1 1 0 0
    + 1 0 0 0 0 0 0 0
    ------------------------
      0 1 1 1 1 1 0 0
    Carry set, overflow set
    


  12. What is 1111 1100 - 1000 0000? Specify if the result has a carry-out set and if the result sets the overflow bit. Show all work.
    Answer:
    Flip bits: 0111 1111
    Adding one achieved by an initial carry-in of 1 below:
      1 1 1 1 1 1 1 1 1
      1 1 1 1 1 1 0 0
    + 0 1 1 1 1 1 1 1
    ------------------------
      0 1 1 1 1 1 0 0
    Carry set, overflow not set
    


  13. What is 0x3F & 0x5A? Provide the answer in two-digit hexadecimal. Show all work.
    Answer:
    0x3F = 0011 1111
    0x5A = 0101 1010
      0 0 1 1 1 1 1 1
    & 0 1 0 1 1 0 1 0
    ------------------------
      0 0 0 1 1 0 1 0
    0001 = 0x1
    1010 = 0xA
    0x1A
    


  14. What is 0x4E | 0xB2? Provide the answer in two-digit hexadecimal. Show all work.
    Answer:
    0x4E = 0100 1110
    0xB2 = 1011 0010
      0 1 0 0 1 1 1 0
    | 1 0 1 1 0 0 1 0
    ------------------------
      1 1 1 1 1 1 1 0
    1111 = 0xF
    1110 = 0xE
    0xFE
    


  15. What is 0x7A ^ 0x14? Provide the answer in two-digit hexadecimal. Show all work.
    Answer:
    0x7A = 0111 1010
    0x14 = 0001 0100
      0 1 1 1 1 0 1 0
    ^ 0 0 0 1 0 1 0 0
    ------------------------
      0 1 1 0 1 1 1 0
    0110 = 0x6
    1110 = 0xE
    0x6E
    


  16. What is ~0x87? Provide the answer in two-digit hexadecimal. Show all work.
    Answer:
    0x8 = 1000
    0x7 = 0111
    Flip bits: 0111 1000
    


  17. What is 1101 0001 << 3? Express your answer in 8-bit binary.
    Answer:
    1000 1000
    


  18. What is 1100 0101 >> 2 for logical shift right? Express your answer in 8-bit binary.
    Answer:
    0011 0001
    


  19. What is 1100 0101 >> 2 for arithmetic shift right? Express your answer in 8-bit binary.
    Answer:
    1111 0001
    


  20. What is 0100 0101 >> 2 for arithmetic shift right? Express your answer in 8-bit binary.
    Answer:
    0001 0001
    


  21. Specify the mask and operation you would need to isolate bit 6 of an unknown 8-bit number. The result of the operation should be 0 (0x00) if bit 6 is 0, and non-zero if bit 6 is 1. The mask should be represented in 8-bit binary.
    Answer:
      XXXX XXXX
    ? ???? ????
    -----------
      0X00 0000 (wanted)
    X & 0 = 0
    X & 1 = X
    X | 0 = X
    X | 1 = 1
    XXXX XXXX
    & 0100 0000 (mask and operation)
    -----------
    0X00 0000
    


  22. Specify the mask and operation you would need to set bits 1 and 4 of an unknown 8-bit number to 1. The result of this operation results in a new number, which the unknown number will be subsequently set to. The mask should be represented in 8-bit binary.
    Answer:
      XXXX XXXX
    ? ???? ????
    -----------
      XXX1 XX1X (wanted)
    X & 0 = 0
    X & 1 = X
    X | 0 = X
    X | 1 = 1
    XXXX XXXX
    | 0001 0010 (mask and operation)
    -----------
    XXX1 XX1X