CSC231 Homework 8 Solution 2014
Homework 8: Solution
- Question 1
- The sum is different because sometimes two of the numbers that are added are so different in magnitude that the smaller one, when it is denormalized, gets its mantissa shifted to the right so much, that its most significant bit has a lower weight than the least significant bit of the other. Remember that the way the addition works, the smaller number gets its exponent raised to be same as the exponent of the larger number, and gets its decimal point shifted left.
- So, adding two numbers that are very different in magnitude will result in the sum equal to the larger of the two numbers.
- Question 2
- Sort in increasing order, and start by adding up the smaller numbers first. This way they have a chance to have their sum grow and influence the magnitude of the larger numbers. For example, I might have a very large number in the series, and 10 smaller numbers, such that each of the smaller number added to the larger one would not change its value. But it could be that when we add the 10 smallest together, their sum is large enough that, when added to the larger number, the result is greater than the larger number (I ignore the sign bit here, for simplicity).
- Question 3
- The test we can use it to see if the difference between the exponent is such that the mantissa of the smallest will be shifted more than 24 bits to the right when denormalized.
- Question 4
- This problem does not happen with multiplication, because multiplication does not require denormalizing the numbers.