Difference between revisions of "CSC231 Final Exam Solutoins 2012"
Line 506: | Line 506: | ||
<br /> | <br /> | ||
+ | =Problem 2= | ||
+ | ==Question 1== | ||
+ | The problem is that FP numbers have to be denormalized before being added, and the smallest number in magnitude must have its mantissa shifted right until its exponent matches the exponent of the largest number, in magnitude. | ||
+ | It is possible that the result is equal to the largest number if the smallest number is shifted so much that it can't affect the least significant bit of the mantissa of the larger number. | ||
+ | |||
+ | ==Question 2== | ||
+ | The rule should be to sort the numbers in increasing order, and start adding with the smallest numbers first. This can be seen as the better solution if the list of numbers is X Y Y Y Y Y Y, where the number Y is smaller than the least significant bit of the mantissa of X. In this case X + Y will be equal to X, and so adding X to any large sequence of Ys will yield X. | ||
+ | |||
+ | If, however, adding Y to itself many times generates a sum that becomes larger than the least significant bit of the mantissa of X, then adding all the Ys first then adding that to X will yield a more "correct" result. | ||
+ | |||
+ | ==Question 3== | ||
+ | Check the exponents of the numbers and see if the difference in exponents between the largest and the smallest exponent is larger than the number of bits in the mantissa. If not, then add up, otherwise sort them first. | ||
+ | |||
+ | =Problem 3= | ||
+ | |||
+ | Nobody saw that you could use a look-up table for this question! Would have made your program so much simpler!!! | ||
+ | |||
+ | But the great majority got at least 90% of the binary pattern to print out... Good! | ||
</onlysmith> | </onlysmith> | ||
Revision as of 14:46, 20 December 2012
--D. Thiebaut 14:37, 20 December 2012 (EST)