Implement two functions for converting between IEEE single-precision floating point and IEEE double-precision floating point.
The s2d routine should take one 32-bit integer as its only argument and should return a 64-bit integer. However, the input value should be interpreted to be actually an IEEE single-precision floating-point value and the return value should be interpreted to be actually an IEEE double-precision floating-point value. The return value should be the result of converting the input IEEE single-precision floating-point value to IEEE double-precision floating point. The conversion should be implemented using only integer operations.
The d2s routine should take one 64-bit integer as its only argument and should return a 32-bit integer. However, the input value should be interpreted to be actually an IEEE double-precision floating-point value. The return value should be the result of converting the input value to IEEE single-precision floating point. The conversion should be implemented using only integer operations.
In both functions, be sure to handle negative, NaN, infinity and denormalized input floating-point values.
Your solution for this assignment should run on agate.cs.unh.edu. This machine uses the Intel implementation of IEEE floating point to convert to and from single-precision and double-precision values. Your implementation should match the Intel hardware exactly.
The files s2d.c and d2s.c in ~cs520/public/prog2 contain stubs for the two functions. You should complete these two functions. If you add helper functions to these files, then hide those functions by using the static keyword.
The ~cs520/public/prog2 directory also contains a simple test rigging for testing s2d in the file testS2D.c. There is also a stub for a test rigging for d2s in the file testD2S.c. Finally, there is a Makefile for compiling the functions and building the two test programs: testS2D and testD2S. If you add additional source code files, then be sure to update this Makefile to incorporate the additional files. As well as updating the testS2D and testD2S Makefile targets, be sure to update the displaySource target, which will be used for printing your source code when the assignment is graded. You will submit this Makefile for grading, whether you changed it or not.
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. I want to see that you applied the principles of problem decomposition, incremental development and incremental testing. Leave your debugging output in your code, but disabled, when you do your final assignment submission.
By the end of the lab on Friday September 17, you should have a fairly complete implementation of s2d. Prior to the lab, do a design for the function. In particular, decompose the problem. I will want to see debugging output to stderr that will display for an input its three basic components: sign, exponent and fraction. And I will want to see debugging output to stderr categorizing an input as infinity, NaN (signaling or quiet), denormalized value, or "regular" value. Use the lab to do your initial implementation and testing of the function.
By the end of the lab on Friday September 24, you should also have a fairly complete implementation of d2s. This means you should design and implement the function prior to coming to lab. Use the lab to do your final testing. When grading this lab, I will re-test your s2d function as well as do initial tests on d2s. You will want to decompose the problem when designing a solution for d2s. I will want to see debugging output to stderr that will display for an input its three basic components: sign, exponent and fraction. And I will want to see debugging output to stderr categorizing an input as infinity, NaN (signaling or quiet), denormalized value, or "regular" value.
Your programs will be graded using agate.cs.unh.edu so be sure to test in that environment.
You should submit your C source code plus the Makefile for compiling your code. The Makefile you submit should have the same functionality as the Makefile distributed for this assignment. Submit this Makefile even if you did not change it. Be sure you disable any debugging output before you submit your assignment.
Your programs should be submitted for grading from
agate.cs.unh.edu.
To turn in this assignment, type:
~cs520/bin/submit prog2 s2d.c d2s.c Makefile
If you introduced additional source code files, then submit those files too. Of course, in this case, you must submit an updated Makefile that processes these additional files too. Be sure to incorporate these files in the displaySource Makefile target.
Please submit only your C source files and the Makefile. Do not turn in any other files!
Also, please do not submit either testS2D.c or testD2S.c. I will supply my own versions of these for grading purposes.
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 September 27. 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.
Comments and questions should be directed to hatcher@unh.edu