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.
- (2 points) Conversion between Binary and Hexadecimal:
Convert the following numbers directly between hexadecimal and binary without first converting to decimal.
- Convert the hexadecimal number 0x9EB36A into binary.
- Convert the binary number 1110101100010110012 into hexadecimal.
- (3 points) Radix-r to Decimal Conversion:
- Convert the binary number 10100101110012 into decimal.
- Convert the hexadecimal number 0x6FB5 into decimal.
- Convert the base-7 number 315627 into decimal.
- (4.5 points) Decimal to Radix-r Conversion:
- Convert the decimal number 215 into binary.
- Convert the decimal number 3576 into hexadecimal.
- Convert the decimal number 171 into base-5.
- (4.5 points) Converting Decimal to Signed Representation:
- Convert the decimal number -89 into 8-bit signed (two's-complement) representation.
- Convert the decimal number 274 into 16-bit signed (two's-complement) representation.
- Convert the decimal number -195 into 16-bit signed (two's-complement) representation.
- (3 points) Interpreting as Signed vs. Unsigned:
- If 110100102 is interpreted as an 8-bit signed (two's-complement) number, what is its decimal value?
- If 110100102 is interpreted as an 8-bit unsigned number, what is its decimal value?
- If 110100102 is interpreted as a 16-bit signed (two's-complement) number, what is its decimal value?
- (4 points) Characters & Strings:
Wikipedia has a copy of the ASCII table, but you can find plenty of sources via Google, if desired.
-
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
-
Convert the string "Billikens rule!" into ASCII.
- (4 points) Operations on Data:
Show the results for the following data operations:
- 11010111101101102 + 00010111000010112
- 0x8F3C5 - 0x3AB2
- 0000000101002 | 0001000100102
- 0000000101002 & 0001000100102