Homework 1
Numbering Systems and Data Types
Due: (in class) Tuesday, October 30, 2007 at 9am
Outcomes
After successfully completing this assignment, you will
be able to...
- convert numbers between the binary, hexadecimal, and decimal
numbering systems
- do simple arithmetic problems in binary and hexadecimal
- show how signed integers are represented in binary
- show how floating point numbers are represented in binary
Before Starting
Read Chapters 1 and 2.
Format and Submission of Assignment
The solution for
this assignment must be submitted as hard-copy at the beginning
of class (9am)
on the due date. All papers must be stapled together, and your name, login
name, and
section number must appear at the top of every sheet. Handwriting must be
legible - if we can't read it, the grade is zero (you may use a word processor
or an editor to write your solution if you wish; please turn in a printed
copy).
Show your work for each problem, and/or explain the steps you are taking to
arrive at the answer. Put a circle around your answer. If you just
give the answer to a problem, without explaining or showing the steps in
obtaining the answer, that problem will be marked wrong.
Problems (each problem is worth 10 points)
-
Perform the following conversions on unsigned numbers. SHOW YOUR WORK.
- a).
1000011100 binary to decimal
- b).
1110000110100101 binary to hexadecimal (no need to show your work for this
part)
- c).
DAB hexadecimal to decimal
- d).
715 decimal to hexadecimal
- e).
227 decimal to binary
-
In the base 6 numbering system there are 6 digits: 0, 1, 2,
3, 4, 5.
Perform the following conversions on unsigned numbers. SHOW
YOUR WORK.
- a).
255 base 6 to decimal
- b).
997 decimal to base 6
-
Perform the following conversions. Assume 16-bit words.
SHOW YOUR WORK.
- a).
Write -114 decimal as a hexadecimal number in sign-magnitude form
- b).
Write -114 decimal as a hexadecimal number in one's complement form
- c).
Write -114 decimal as a hexadecimal number in two's complement form
-
An 8-bit word contains the bit pattern 10000110. What decimal number
does this represent if the word is
- a). an unsigned number
- b). a signed number in two's complement form
-
To convert a floating point number from decimal to binary, the integer and
fractional parts
must be considered separately. In class, we saw how to convert the integer
portion by doing repeated divisions by 2. The fractional part involves
repeated multiplications by 2. At each step, the fractional part of the
decimal number is multiplied by 2. The digit to the left of the decimal
point in the product will be 0 or 1 and contributes to the binary
representation of the fraction, starting with the most significant bit. The
fractional part of the product is used as the multiplicand in the next step.
Continue until the product contains a fractional part equal to 0, for exact
representations.
EXAMPLE: Convert 4.625 decimal to binary
Integer portion: 4 decimal = 100 binary
Fractional portion:
0.625 x 2 = 1.25 ==> .1
0.25 x 2 = 0.5 ==> 0
0.5 x 2 = 1.0 ==> 1
fractional portion of product is zero, so stop
4.625 decimal = 100.101 binary
Note, however, that the process will not necessarily yield an exact
representation. Just as some fractions
cannot be represented exactly in the decimal numbering system (e.g. 1/3),
neither can some fractions be represented exactly in the binary numbering
system (e.g. 1/10). In cases that do not yield an exact result, continue
until you find a repeating fraction, or for twenty-three binary places, whichever
comes first.
- a).
Convert -100.375 decimal to IEEE single-precision format (see pp 37 - 40
in the textbook).
Give the results as 8 hexadecimal digits. SHOW YOUR WORK.
- b).
Convert 41D00000 hex (which is in IEEE single-
precision format) to a decimal floating point number. SHOW YOUR WORK.
-
Compute the sum of the following IEEE single-precision floating point
numbers and express the result as a hexadecimal number. The numbers to
be added are given in hexadecimal: 41280000, 40700000. (Hint: the
exponents must be the same when you add two numbers in floating point
format, same as you would do if you added two numbers that were specified
using
scientific notation).
-
- a). Represent the values 12 and -11 as 8-bit 1's complement integers.
Add the two binary representations. What is the binary result? What decimal
value does that 1's complement result represent?
- b). Represent the values 12 and -11 as 8-bit signed magnitude integers.
Add the two binary representations. What is the binary result? What decimal
value does that signed magnitude result represent?
- c). Represent the values 12 and -11 as 8-bit 2's complement integers.
Add the two binary representations. What is the binary result? What decimal
value does that 2's complement result represent?
- Perform the following additions on 16-bit hexadecimal values. Provide your answers
as 16-bit hexadecimal values.
- a). x034A + x2FF6 (notice the addition of two two's-complement positive values gives
a positive result)
- b). xFFD4 + xFFF1 (notice the addition of two two's-complement negative values gives
a negative result)
- c). xB123 + xC777 (explain why the addition of two two's-complement negative numbers
results in a two's-complement positive number)
-
- a). Do problem 2.22 from the textbook.
- b). Do problem 2.24 from the textbook.
-
- a). Do problem 2.34 from the textbook.
- b). Do problem 2.54 from the textbook.