Make your FloatAdd function handle these eight cases:
The fifth and sixth test cases will require you to support negative inputs. If both inputs are negative, then you add the significands (after aligning the exponents) and set the sign bit when encoding the result. If the inputs have different signs, then subtract the value with the smaller magnitude from the value with the larger magnitude (after aligning the exponents), and the sign of the result is the sign of the value with the larger magnitude.
The seventh and eighth test cases require you to normalize the result. In one case you will have two bits to the left of the radix point and you will need to shift right one position and add one to the exponent. In the other case you will need to shift left until the value is normalized, subtracting from the exponent the distance that you need to shift. Remember anytime you add or subtract from the exponent then you need to worry about underflow and overflow.
You will have to construct a main program to test these eight cases. But do not submit this main program! Put it in a separate file.
You must turn-off any debugging code before you submit your lab.
Note: you are only submitting the one file, FloatAdd.c, so do not put any of your code in any other file. In particular, FloatAdd.c should not include any files that you created. It should only include standard system header files.
To turn in this laboratory, type:
Submissions can be checked by typing:
Comments and questions should be directed to
hatcher@unh.edu
~cs520/bin/submit lab4 FloatAdd.c
~cs520/bin/scheck lab4
Last modified on February 2, 2014.