DOCERR: Iteration Count Overflow in 5.0 and 5.1 Manuals

Last reviewed: July 17, 1995
Article ID: Q70193
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 5.1

SUMMARY

On pages 149 and 150 of the version 5.0 and version 5.1 "Microsoft FORTRAN Reference" manual, the iteration count for DO loops is incorrectly stated to default to INTEGER*2 storage. DO loop iteration counts actually appear to default to the same precision as the DO variable, except when the start value and stop value are constants, rather than variables. In this case, the DO loop iteration count appears to default to INTEGER*4 storage.

MORE INFORMATION

Page 150 states that "The iteration count is computed using two-byte precision (the default)", and the code on page 150 of the Reference Manual illustrates an iteration overflow when compiled with /4Yb or $DEBUG. However, declaring the DO variable 'n' as integer*4 or removing the IMPLICIT statement removes the iteration overflow, indicating that the iteration count precision is dependent on the precision of the DO variable. This is demonstrated by the code below, which both compiles and runs without errors, even when compiled with /4Yb or $DEBUG:

Sample code

$DEBUG

      IMPLICIT INTEGER*2 (A-Z)
      INTEGER*4 N
      stop=32000
      start=0
      step=1200
      DO 100 n=start,stop,step
100 CONTINUE
      END

Declaring the DO variable as INTEGER*2 and the rest of the variables as INTEGER*4 generates an integer overflow error when compiled with /4Yb or $DEBUG.

Sample code

$DEBUG

      INTEGER*4 start,stop,step
      INTEGER*2 N
      stop=32000
      start=0
      step=1200
      DO 100 n=start,stop,step
100 CONTINUE
      END

Therefore, the iteration count precision is dependent on the precision of the DO variable. Furthermore, the code on page 149 does not cause the iteration overflow error as stated. This code is as follows:

Sample code

$DEBUG

      INTEGER*2 i
      DO 10 i=-32000,32000,1
10 CONTINUE
      END

This code executes without error when compiled with /4Yb or $DEBUG, indicating that when constants are used for the start and stop values, the iteration count defaults to INTEGER*4 precision.


Additional reference words: 5.00 5.10 docerr
KBCategory: kbprg kbdocerr kbcode
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.