Comp 212 Project 2
Accurate Floating-Point Sum

Due April 3, 2000 at 10:00 AM

The accuracy of floating-point arithmetic is limited by the fact that floating-point numbers are implemented using a finite number of digits. Internally, the implementation of floating-point numbers is similar to a number written in scientific notation, for example, -5.678 * 109. In other words, the sign (-), the mantissa (5.678), and the exponent are stored as separate fields, and the number of digits in the mantissa and exponent is fixed.

If we add a very large number with a very small number, our result may (incorrectly) be just the larger number. The reason is that to add the numbers we must, normalize them, that is, they need to have the same exponent. Usually, we change the smaller number to have the same exponent as the larger number. So, for example, if we normalize -5.678 * 109 and 5.432 * 101, 5.432 * 101 becomes 0.000 * 109, because we've insufficient digits in the mantissa. Ooops.

To avoid this problem, one possible way to sum a list of positive floating-point numbers is as follows.

Your program should accept a list of (possibly negative) floating-point numbers as input through the standard input stream, with one floating-point number per line. It should recognize the end of the list when this stream reports end-of-file (EOF). It should then compute and print the sum to the standard output stream.

Your priority queue must be based upon a heap. You should apply the ``Object'' Adapter Pattern to construct a priority queue from a heap. Your ordered container must be based upon the circular list presented in class. Again, you should apply the ``Object'' Adapter Pattern. Furthermore, the ordered container's methods should be implemented as Visitors to the circular list.

Code samples are provided for your convenience!

Submission

The project is broken up into two milestones.  Each milestone is to be submitted electronically.  You can use slack days on this project.  You are given a total of five slack days for the whole semester. Specific submission instructions will be posted on the Comp212 web page.  The complete milestone set should contain the following:

Milestone #1: due March 27, at 10:00 AM - the priority queue and ordered container classes as well as testing code for these classes.  40% of the project grade

Milestone #2: due April 3, at 10:00 AM - the complete program. 60% of the project grade


alc@cs.rice.edu  dxnguyen@cs.rice.edu         Please let us know of any broken links             Revised Feb 07, 2000