Download Quiz2-solution

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1. (5 points) How -123 would be represented as an 8-bit, 2s-complement binary
number?
Ans: 1000 0101
2. (10 points) What is an integer overflow? How is it detected? Why is it relevant
during the execution of an slt instruction?
ANSWER: Integer overflow occurs when the magnitude of a number becomes
too large to represent in 32 bit 2’s complement form. It is detected in
the ALU when the result of an operation produces an unexpected sign
(e.g., the addition of two positive numbers produces a negative
number). It is relevant during the execution of an slt operation
because the sign resulting from the subtraction is feedback to the low
order bit ALU as it’s result bit and thus it has to be modified in the
case of an overflow.
3. (10 points) How would the number 23.625 be represented as a 32 bit single
precision number according to the IEEE Floating Point Standard?
ANSWER: 0100 0001 1011 1101 0000 0000 0000 0000
4. (10 points) What decimal number does the following 32 bit single precision IEEE
floating-point standard number represent?
1100 0000 1111 0000 0000 0000 0000 0000
ANSWER: sign bit: 1
exponent: 1000 0001
significand: 1110 .111 in
binary is 1/2+1/4+1/8=.875 and 10000001 is 129, so we have
-1*(1+.875)*2**(129-127) = -1.875*2**2 = -7.5
5. (15 points) Perform 5 x -3 using Booth’s Algorithm using a 5-bit representation
for each operand. Show all your work. Also indicate how the results of the
multiplication should be interpreted.
Answer: Multiplicand = 5 (00101)
-5 = (11011)
product: 0 00000 11101 0
subt:
1 11011 11101
shift:
1 11101 11110 1
add:
0 00010 11110
shift:
0 00001 01111 0
subt:
1 11100 01111
shift:
1 11110 00111 1
shift:
1 11111 00011 1
shift:
1 11111 10001
Multiplier = -3 (11101)
product = 10001 = -15 in two’s complement representation
upper 5 bits = 11111 (sign-extended lower 5 bits), therefore, no overflow
Related documents