Write a C 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, infinity and denormalized inputs and results.
Your solution for this assignment should run on agate.cs.unh.edu. This machine uses the Intel implementation of IEEE floating point. Your implementation should match the Intel hardware exactly.
The directory ~cs520/public/prog2 contains a stub for FloatAdd.
Your program will be graded primarily by testing it for correct functionality:
You should use #if C preprocessor commands to allow your debugging prints to be easily turned on or off. For example,
#define DO_DEBUGGING_PRINTS 1 #if DO_DEBUGGING_PRINTS fprintf(stderr, "this is debugging output\n"); #endifBy simply changing the 1 to a 0 in the definition of DO_DEBUGGING_PRINTS, the debugging output can be disabled. You want the debugging output to be enabled for the submission of Lab 3, but be sure you disable any debugging output before you submit Lab 4 and Program 2.
In addition, remember, you may lose points if your program is not properly structured or adequately documented. See the mandatory guidelines given in the course overview webpage.
Your programs will be graded using agate.cs.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. Make sure this file does not contain a main function. And be sure to turn off the debugging output.
Your programs should be submitted for grading from
agate.cs.unh.edu.
To turn in this assignment, type:
~cs520/bin/submit prog2 FloatAdd.c
Submissions can be checked by typing:
~cs520/bin/scheck prog2
This assignment is due Wednesday September 28. The standard policy concerning late submissions will be in effect. See the course overview webpage.
Remember: as always you are expected to do your own work on this assignment. Copying code from another student or from sites on the internet is explicitly forbidden!
Comments and questions should be directed to pjh@cs.unh.edu