Assignment 2
Assignment 2
Instructions: For each problem, explain your solution or show the steps of your solution. No credit will
be given for answers only.
2. [12 points] Complete the following table. All binary numbers are 8-bit signed integers.
Sign-magnitude Ones’ complement Two’s complement
Decimal value
representation representation representation
-112
11101011
01100101
10111101
3. [15 points] Consider an 8-bit two’s complement representation. Let TMin be the most negative
integer and TMax be the most positive integer. Fill in the following table. Fill in the following table:
TMax
TMin
-TMax
-TMin
TMax + 1
TMin - 1
TMax + Tmin
4. [12 points] Suppose you are given the task of generating code to multiply an integer variable 𝑥 by
various constant factors 𝐾. For the following values of 𝐾, write C expressions to perform the
multiplication using only use only operators +, -, and <<.
a. 𝐾 = 18
b. 𝐾 = −33
c. 𝐾 = −96
5. [15 points] For each of the following, you are to write a C function that performs the indicated
computation using only the following C operators: !, ~, &, ^, |, +, <<, and >>. Moreover, your
function should use only straight-line code (i.e., no loops or conditionals). You may assume that an
int is 32 bits wide.
50:198:331 Introduction to Computer Organization Assignment 2
6. [14 points] Let 101010112 and 100100112 be two signed integers in two’s complement representation.
a. Determine the decimal values of the two numbers.
b. Using the binary multiplication algorithm described in class (and in the lecture notes), find the 16-bit
product of 10101011 ´ 10010011.
7. [20 points] Let 4094000016 and 3f30000016 represent two floating-point numbers in IEEE single-
precision FP format.
a. Determine the decimal values of the two numbers.
b. Add the two numbers and show the result both in IEEE single-precision FP format and in decimal.
c. Multiply the two numbers and show the result both in IEEE single-precision FP format and in decimal.