CS520
Fall 2005
Programming Assignment 2
Due Sunday October 9


Write a function, FloatAdd, to emulate IEEE 32-bit (single-precision) floating point addition.

The routine should take two 32-bit integers as arguments and should return a 32-bit integer. However, the 32-bit integers should be interpreted to be actually floating point values. The return value should be the result of performing the IEEE addition algorithm on the two inputs. The floating point addition should be implemented using only integer operations.

Be sure to handle NaN and Infinity inputs and results. However, you do not need to fully handle "denormalized" inputs or results. Consider denormalized values to be zero.

Your solution for this assignment should run on a CIS Linux machine. These machines all use the Intel implementation of IEEE floating point.

Implement rounding using two guard bits, a sticky bit, and "round to even". (These techniques will be discussed in class.) Be aware that by default Intel hardware does the floating point addition in 80 bits, which may cause different answers from the rounding algorithm given in class.

However, in other cases your emulation should return the exact same value as the Intel hardware.

The directory ~cs520/public/prog2 contains a stub for FloatAdd, as well as a Makefile and a main routine. This main routine performs basic tests of FloatAdd. You should devise additional tests.

Your program will be graded primarily by testing it for correct functionality:

In addition, remember, you may lose points if your program is not properly structured or adequately documented.

Your programs will be graded using an CIS Linux machine (e.g. turing.unh.edu) so be sure to test in that environment.

You should submit all the source code for your implementation of the FloatAdd routine in a single file called FloatAdd.c.

Your programs should be submitted for grading from a UNH CIS Linux machine (e.g. turing.unh.edu). To turn in this assignment, type:
~cs520/bin/submit prog2 FloatAdd.c

Please submit only your C source file. Do not turn in any other files!

Submissions can be checked by typing:
~cs520/bin/scheck prog2

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday October 10. Programming assignments may be handed in late at a penalty of 2 points for one day late, 5 points for two days late, 10 points for three days late, 20 points for four days late, and 40 points for five days late. No program may be turned in more than 5 days late.

Remember: as always you are expected to do your own work on this assignment.


Last modified on August 22, 2005.

Comments and questions should be directed to hatcher@unh.edu