Skip to main content
Engineering LibreTexts

1.10: Exercises

  • Page ID
    28375
    1. What are the following numbers in binary and hexadecimal?
      1. 1310
      2. 1510
      3. 2510
      4. 15710
      5. 32510
      6. 109610
    2. What are the following numbers in decimal?
      1. 100111002
      2. 9C16
      3. 1F16
      4. 0C16
      5. 109A16
    3. Give the value of the following numbers (IE. 232 = 4G)
      1. 216
      2. 224
      3. 229
      4. 234
      5. 231
    4. Give the 2’s complement form for each of the following numbers:
      1. 13
      2. -13
      3. 156
      4. -209
    5. Do the following calculations using 2’s complement arithmetic. Show whether there is an overflow condition or not. CHECK YOUR AnswerS!
      1. 13 + 8 with 5 bits precision
      2. 13 + 8 with 6 bits precision
      3. 13 – 8 with 5 bits precision
      4. 13 – 8 with 6 bits precision
      5. -13 – 8 with 5 bits precision
      6. -13 – 8 with 6 bits precision
      7. 105 – 57 with 8 bits precision
    6. Do the following multiplication operations using binary shift operations. Check your answers.
      1. 5 * 4
      2. 13 * 12
      3. 7 * 10
      4. 15 * 5
    7. What is the hex representation of the following numbers (note that they are strings):
      1. “52”
      2. “-127”
    8. Perform the following multiplication and division operations using only bit shifts.
      1. 12 * 4
      2. 8 * 16
      3. 12 * 10
      4. 7 * 15
      5. 12 / 8
      6. 64 / 16
    9. Explain the difference between a short circuiting and non short circuiting logical expression. Why do you think these both exist?
    10. In your own words, explain why the context of data found in a computer is important. What provides the context for data?
    11. Convert the following ASCII characters from upper case to lower case. Do not refer to the ASCII table.
      1. 0x41 (character A)
      2. 0x47 (character G)
      3. 0x57 (character W)
    12. Convert the following ASCII characters from lower case to upper case. Do not refer to the ASCII table.
      1. 0x 62 (character b)
      2. 0x69 (character i)
      3. 0x6e (character n)
    13. Write the functions toUpper and toLower in the HLL of your choice (C/C++, Java, C#, etc.) The toUpper function converts the input parameter string so that all characters are uppercase. The toLower function converts the input parameter string so that all characters are lowercase. Note that the input parameter string to both functions can contain both upper and lower case letters, so you should not attempt to do this using addition.
    14. Implement a program in the HLL of your choice that converts an ASCII string of characters to an integer value. You must use the follow pseducode algorithm:
      read numberString 
      outputNumber = 0
      while (moreCharacters) {
          c = getNextCharacter
          num = c - '0';
          outputNumber = outputNumber * 10 + num;
      }
      print outputNumber;
      
    15. Write a program in the HLL of your choice to take a string representing a binary number, and write out the number in hex.
    16. Write a program in the HLL of your choice to take an integer and write its value out in hex. You cannot use string formatting characters.
    17. Is bit shift by 1 bit the same as division by 2 for negative integer numbers? Why or why not?
    18. Can multiplication of two variables (not constants) be implemented using the bit shift operations covered in this chapter? Would you consider using the bit shift operations implementation of multiplication and divide for two variables, or would you always use the mul or div operators in MIPS assembly? Defend your choice.
    19. Should you use bit shift operations to implement multiplication or division by a constant in a HLL? What about assembly makes it more appropriate to use these operations?
    20. What does the Unix strings command do? How does the command attempt to provide a context to data? How might you use it?
    • Was this article helpful?