Assignment #1: Data Representation and Operations
Assigned: Monday, September 11th
Due: Wednesday, September 20th
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
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.
- (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 0x1E7BF6 into binary.
- Convert the binary number 1101010011101001102 into hexadecimal.
- (3 points) Radix-r to Decimal Conversion:
- Convert the binary number 11011010001102 into decimal.
- Convert the hexadecimal number 0x5B6F into decimal.
- Convert the base-7 number 265137 into decimal.
- (4.5 points) Decimal to Radix-r Conversion:
- Convert the decimal number 247 into binary.
- Convert the decimal number 2465 into hexadecimal.
- Convert the decimal number 207 into base-5.
- (4.5 points) Converting Decimal to Signed Representation:
- Convert the decimal number -76 into 8-bit signed (two's-complement) representation.
- Convert the decimal number 434 into 16-bit signed (two's-complement) representation.
- Convert the decimal number -165 into 16-bit signed (two's-complement) representation.
- (3 points) Interpreting as Signed vs. Unsigned:
- If 101011012 is interpreted as an 8-bit signed (two's-complement) number, what is its decimal value?
- If 101011012 is interpreted as an 8-bit unsigned number, what is its decimal value?
- If 101011012 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:
- 11010110011110112 + 00010111000010112
- 0x8F3C5 - 0x4BC3
- 0011000101002 | 0001110101002
- 0011000101002 & 0001110101002