MCS 471 --- Computer Problem 0 --- Spring 1997
Floating Point Arithmetic
Single program with computer output is due Friday 07 Feb 1997 in class.
Write a single program that combines the two following finite precision
problems. You may use WATFOR77, regular Fortran, Pascal or C (Maple may
also be used provided digits chopping precision is specified like 7 or 16
and reasonable effort made to follow the spirit of the problem)
on the computer of your choice within reason for this problem.
However, you must hand in both copies of your program source code
and your computer output.
Determine the single and double precision machine epsilon,
MIN(EPS | EPS>0 & 1+EPS>1)
using the modification that follows of a "bisectioning approximation"
(TEPS is the temporary approximate machine epsilon) code fragment:
TEPS=1
KMAX=100
K=1
1 PRINT,TEPS,TEPS+1
IF(TEPS+1.LE.1..OR.K.GT.KMAX) GOTO 2
TEPS=TEPS/2
K=K+1
GOTO 1
2 EPS=2*TEPS
PRINT,`FINAL ANSWER; K=',K
PRINT,EPS,EPS+1
PREC=1-LOG(EPS)/LOG(2.)
Modify this code for your computer and programming language with
print statements to print out the results AND
- Name of Your Computer System with Processor if not well known,
- Name of Your Progamming Language Compiler version if not well known,
- Intermediate values of "TEPS" and "TEPS+1",
- Final Approximation the Machine Epsilon in "EPS",
- Final Approximation of the Precision in "PREC",
- The Same Three (3) Items from a modified copy of the above code fragment,
modified for Double Precision (64bit=8bytes word)
NOTES:
- You need results in both single (32bit) and double (64bit) precision
floating arithmetic.
- The answer is in statement 2 where the failed previous value is corrected
since it failed the "TEPS+1>1" test.
- The variable "PREC" gets the approximate number
of binary digits in the machine precision of the floating point fraction.
Does this value correspond to the theoretical precision derived in class?
- Why is CHOPPING rather than up/down ROUNDING demonstrated?
- The "LOG" logarithm function must be appropriately declared in
FORTRAN. You also must output in double precision (REAL*8 or DOUBLE PRECISION).
- For C, you will have to use "float" for single precision and "double"
for double precision.
- For Pascal, you will have to use "real" for single precision and
"double" for double precision. However, different versions have different
names for precision. Also, "ln(x)" is the logarithm function in Pascal.
- For the UIC "icarus" or other IBM RS6000 and single precision,
you must set something like "-qautodbl=none" or else your single precision
results will be the same as double precision case. It is not clear what
can be done to turn off autodoubling for "cc", "gcc" or "xlc" on "icarus".
- Some PC with other compilers also can us autodoubling, so you have to
find some way to turn it off for single precision, or try to use any two
different floating point precisions.
Web Source: http://www.math.uic.edu/~hanson/mcs471cp0.html
Email Comments or Questions to Professor Hanson