| FIX: F6099: Int Overflow Unreported on Exponential MathLast reviewed: September 16, 1997Article ID: Q86063 | 
| 4.00 4.01 4.10 5.00 5.10 | 4.10 5.00 5.10 MS-DOS | OS/2kbtool kbbuglist kbfixlist kberrmsg kbcode The information in this article applies to: 
 
 SYMPTOMSPrograms compiled with Microsoft FORTRAN version 4.0, 4.01, 4.1, 5.0, or 5.1 with the /4Yb compiler option or the $DEBUG metacommand may not report the following run-time error message 
 run-time error F6099: $DEBUG - INTEGER overflowif an integer is raised to a power, which is an integer other than 2. If the exponent is a REAL number, the following error may be generated: 
 run-time error M6101: MATH -floating-point error:invalid CAUSEThe /4Yb compiler option or $DEBUG metacommand directs the compiler to do testing for INTEGER overflow, but it fails to do this for the exponential arithmetic if the exponent is an integer other than 2. If the exponent is 2, the algorithm is implemented as simple multiplication and the INTEGER overflow error is generated. In the case of REAL exponents, INTEGER overflow is still incorrectly not being checked; however, a floating-point math exception eventually is generated because intermediate values are being computed using floating-point values. 
 RESOLUTIONCode should be written to check INTEGERS that are raised to a power for overflow. 
 STATUSMicrosoft has confirmed this to be a problem in Microsoft FORTRAN versions 4.0, 4.01, 4.1, 5.0, and 5.1 for MS-DOS and OS/2. This problem was corrected in FORTRAN PowerStation, version 1.0. 
 MORE INFORMATIONThe following code reproduces the problem: 
 Sample Code 1$debug       integer i, j, m
      m = 500
      do i=1,100000
        j=m**i ! This line will not generate an INTEGER overflow.
        k=(m+i*1000)**2
c This line will generate the overflow error because n**2 is
c implemented as multiplication (n*n) and doesn't use exponentiation.
         write(*,*) 'j=',j
        write(*,*) 'k=',k
      end do
      end
Sample Code 2The following code is an example of a way of avoiding INTEGER overflows. $debug       integer i
      real    max, check
      max = huge(i)
      k = 500
      do i=1,100000
        check = max**float( 1./float(i) )
        print*, i , check , k**i
        if (float(k).ge.check) stop 'Integer overflow'
      end do
      end
 | 
| Additional reference words: 4.00 4.10 5.00 5.10 buglist5.00 buglist5.10 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use. |