Assignment #1: Data Representation and Operations


Assigned: Friday, January 27th
Due: Friday, February 3rd

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)

When you turn in your assignment, you must include a signed cover sheet (PDF version) with your assignment (your assignment will not be graded without a completed cover sheet).

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.

  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 0x9EB36A into binary.
    2. Convert the binary number 1110101100010110012 into hexadecimal.
  2. (3 points)    Radix-r to Decimal Conversion:
    1. Convert the binary number 10100101110012 into decimal.
    2. Convert the hexadecimal number 0x6FB5 into decimal.
    3. Convert the base-7 number 315627 into decimal.
  3. (4.5 points)    Decimal to Radix-r Conversion:
    1. Convert the decimal number 215 into binary.
    2. Convert the decimal number 3576 into hexadecimal.
    3. Convert the decimal number 171 into base-5.
  4. (4.5 points)    Converting Decimal to Signed Representation:
    1. Convert the decimal number -89 into 8-bit signed (two's-complement) representation.
    2. Convert the decimal number 274 into 16-bit signed (two's-complement) representation.
    3. Convert the decimal number -195 into 16-bit signed (two's-complement) representation.
  5. (3 points)    Interpreting as Signed vs. Unsigned:
    1. If 110100102 is interpreted as an 8-bit signed (two's-complement) number, what is its decimal value?
    2. If 110100102 is interpreted as an 8-bit unsigned number, what is its decimal value?
    3. If 110100102 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.   11010111101101102   +   00010111000010112
    2.   0x8F3C5   -   0x3AB2
    3.   0000000101002   |   0001000100102
    4.   0000000101002   &   0001000100102