Overflow Example
Program example that generates overflows and underflows:
Output with all exceptions ignored by default:
setenv TRAP_FPE “UNDERFL=TRACE; OVERFL=TRACE“
will trap at Overflow and Underflow and produce traceback (Link -lfpe).
INCLUDE “/usr/include/limits.h”
A(I) = (FLT_MAX/10)*I ! single precision range
B(I) = (FLT_MIN*10)/I ! will fit into double
C = CMPLX(A,B) ! Standard requires passing from base precision: real*4 !
write (0,’(I3,2(2G22.15/))’) (I,A(I),B(I),C(I),I=1,N)
10 0.340282347000000E+39 0.117549435000000E-37 A,B
0.340282346638529E+39 0.117549435082229E-37 Cr,Ci
11 0.374310581700000E+39 0.106863122727273E-37
Infinity 0.000000000000000
Compile with: f77 -n32 -mips4 -O3
Note: Compilation with -r8 avoids the error.