
CSCI 463 Assignment 2 Due: 02/02/07 (3rd Week)
Spring-2007 (100 pts)
C/C++ Program for Simulating
8-bit, 10-bit & 32-bit Floating-Point Formats
Review the material in Section 2.5: Floating-Point Representation (pp. 63-74) of
our text(by Null & Lobur) to further understand the principles in Floating-Points.
The Floating-Point Formats of 8-bit, 9-bit, and 32-bit in this assignment are
simplified versions of the IEEE-754 Floating-Point Standard (see Section 2.5.4).
Part I (20 points)
1. From the course web page, http://www.cs.niu.edu/~sjchung,
copy Float8.c, Float8.in and Float8.sjc.
2. The format used in Float8.c & Float32.c is not the IEEE 754 (Appendix B.2).
It is much simpler than the IEEE 754. Instead, the " Biased-Exponent" are
used for the Exponent field. See below for ABiased-Exponent.@
3. Float8.c assumes the Floating-Point Format: 1-bit Sign,
4-bit Biased-Exponent (Characteristic), and 3-bit Mantissa (Fraction).
4. For example, consider the decimal 2.75.
1) Converting it to binary, we have: 10.11
2) Normalizing it, we get: 0.1011 x 22
3) 0 is stored as Sign (1 if the value were negative)
4) 101 is stored as Mantissa (losing the last digit for lack of space)
5) The exponent 2 is:
a) Converted to binary 10, then
b) Exponent 10 (in binary) stored as 1010 ("Biased-8 Exponent")
6) Note: -----------------------------------------------------
Biased-Exponent 1111 1110 1001 1000 0111 0000
-----------------------------------------------------
"True" Exponent 7 6 1 0 -1 -8
-----------------------------------------------------
5. Using the Turbo C++ (or any other similar C compiler),
compile & link/edit ("Build") Float8.c to get Float8.obj & Float8.exe.
6. Run Float8.exe by: Float8 < Float8.in > Float8.out
Your Float8.out should compare correctly to Float8.sjc.
7. Hand in:
1) printed copy of your Float8.out
2) your 3.5" diskette containing your Float8.obj, Float8.exe, and Float8.out
Part II (30 points)
Hand in Page 2 of this assignment after you complete the Questions.
Part III (50 points)
1. Write Float32.c, a program in C, that uses the Floating-Point Format:
1-bit Sign, 7-bit Characteristic, and 24-bit Mantissa.
2. Compile, link/edit, and run by: Float32 < Float32.in > Float32.out.
Your Float32.out should compare correctly to Float32.sjc.
3. Make sure that your Float32.c is well-documented.