The SIZE ERROR clause allows the programmer to specify actions to be taken when a size error occurs in an arithmetic statement. A size error condition exists under the following circumstances:

  1. The absolute value of an operation's result exceeds the largest value the resultant data item can contain.
  2. A division by zero is performed.
  3. The value zero is raised to a power of zero.
  4. A negative number is raised to a non-integer power.

The size error condition exists only for those resultant data items to which it applies. If the ROUNDED phrase is specified, it is applied before the size error condition is checked.

If a size error occurs, the results depend on whether or not the SIZE ERROR (or NOT SIZE ERROR) clause is specified. If the SIZE ERROR clause is present, the values of the data items on which a size error occurs remain unchanged. If there are multiple resultant data items in the statement, the ones on which size errors occur will be unchanged while the ones in which no size error occurs will be updated to the computed values. If a size error occurs and no SIZE ERROR clause is specified, the results are undefined. In cases where the size error is a divide by zero condition, by default the results are still undefined, however, the A_CECKDIV configuration variable can be used to specify either of two alternate runtime behaviors. For more information, see A_CHECKDIV.

If the SIZE ERROR clause is present and a size error occurs, the corresponding statement is executed. If the NOT SIZE ERROR clause is present, its statement is executed if no size errors occur during the computation.

If the CORRESPONDING option is used in an ADD or SUBTRACT statement, any individual operation can cause a size error to occur. The SIZE ERROR clause is not executed, however, until all individual operations are completed.