DOCERR: Iteration Count Overflow in 5.0 and 5.1 ManualsLast reviewed: July 17, 1995Article ID: Q70193 |
The information in this article applies to:
SUMMARYOn 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 INFORMATIONPage 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,step100 CONTINUE ENDDeclaring 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,step100 CONTINUE ENDTherefore, 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,110 CONTINUE ENDThis 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |