Assignment #1: Data Representation and Operations


Assigned: Monday, September 11th
Due: Wednesday, September 20th

Contents:


Overview

Topic(s): Numeric Representation, Binary and Hexadecimal, Place Value, Converting between Bases, Characters & Strings, and Operations on Data
Related Reading: class notes, and Chapter 2 of Bryant and O'Hallaron


Practice Problems


Problems to be Submitted (25 points)

You are allowed to submit your assignment via email, but if you choose to do so, you must bring a hardcopy of your assignment along with a completed cover sheet to the instructor at the next class. (Note: Do not email the instructor any .zip file attachments, as SLU's email may not accept these emails; i.e. the instructor may not receive your email.)

Note: It is important that you show your work for all these numeric conversions. Problems submitted without showing work will be given ZERO CREDIT.

  1. (2 points)    Conversion between Binary and Hexadecimal:
       Convert the following numbers directly between hexadecimal and binary without first converting to decimal.
    1. Convert the hexadecimal number 0x1E7BF6 into binary.
    2. Convert the binary number 1101010011101001102 into hexadecimal.
  2. (3 points)    Radix-r to Decimal Conversion:
    1. Convert the binary number 11011010001102 into decimal.
    2. Convert the hexadecimal number 0x5B6F into decimal.
    3. Convert the base-7 number 265137 into decimal.
  3. (4.5 points)    Decimal to Radix-r Conversion:
    1. Convert the decimal number 247 into binary.
    2. Convert the decimal number 2465 into hexadecimal.
    3. Convert the decimal number 207 into base-5.
  4. (4.5 points)    Converting Decimal to Signed Representation:
    1. Convert the decimal number -76 into 8-bit signed (two's-complement) representation.
    2. Convert the decimal number 434 into 16-bit signed (two's-complement) representation.
    3. Convert the decimal number -165 into 16-bit signed (two's-complement) representation.
  5. (3 points)    Interpreting as Signed vs. Unsigned:
    1. If 101011012 is interpreted as an 8-bit signed (two's-complement) number, what is its decimal value?
    2. If 101011012 is interpreted as an 8-bit unsigned number, what is its decimal value?
    3. If 101011012 is interpreted as a 16-bit signed (two's-complement) number, what is its decimal value?
  6. (4 points)    Characters & Strings:
       Wikipedia has a copy of the ASCII table, but you can find plenty of sources via Google, if desired.
    1. What is the string corresponding to the following series of ASCII values:
             0x54 0x68 0x69 0x73 0x20 0x69 0x73 0x20 0x41 0x53 0x43 0x49 0x49 0x21 0x00
    2. Convert the string "Billikens rule!" into ASCII.
  7. (4 points)    Operations on Data:
       Show the results for the following data operations:
    1.   11010110011110112   +   00010111000010112
    2.   0x8F3C5   -   0x4BC3
    3.   0011000101002   |   0001110101002
    4.   0011000101002   &   0001110101002