Arithmetic overflow checking

No computer permits the storage and manipulation of arbitrarily large quantities. The following limits apply when using FTN95:

INTEGER (KIND=1)

-128 to +127

INTEGER (KIND=2)

-32768 to +32767

INTEGER (KIND=3)

-2147483648 to +2147483647

REAL (KIND=1)

(1E-37 to 1e+39) (approx.)

DOUBLE PRECISON

(1D-307 to 1D+309) (approx.)

 

If a calculation is performed whose result exceeds these limits arithmetic overflow occurs.

If a CHECK directive appears in the source pro gram, then runtime checking for overflow is enabled.

If a checked statement does set overflow then execution is terminated and the interactive debugger is entered. If a statement sets overflow and is not checked, then execution continues with an in correct result in the case of integers, but terminates in the floating point case.

When a program is loaded, all numeric variables (except those which have appeared in a DATA statement) are initialised to an "undefined" value unless the /ZEROISE compile-time option is used.

In the case of integer variables, the undefined value chosen is -32640 which will not result in overflow being set as the result of an assignment and, furthermore, overflow will not always occur when an expression is evaluated which involves an undefined value.

Undefined variables can be trapped by use of the /UNDEF option (see below).

Note:
Variables and array elements in otherwise uninitialised common blocks are not initialised to the undefined value.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited