Handling Errors in Floating-Point Computations

IBM® i provides a group of Computation Attributes (CA) MI instructions to retrieve information about floating-point operations and to change the way floating-point operations behave. For example, the SETCA (Set Computational Attributes) MI instruction can prevent certain floating-point exceptions from occurring, as well as indicating whether or not rounding is done. By default, the result of a floating-point operation is always rounded, and all of the exceptions, except for Invalid Operand are signalled.

The exceptions that can be prevented are floating-point:
  1. Overflow
  2. Underflow
  3. Zero divide
  4. Inexact result
  5. Invalid operand

For ON SIZE ERROR phrase handling, ILE COBOL requires that the first 3 exceptions must be signaled.

ILE COBOL also requires rounding to the nearest decimal position to take place, which means if you used the CA MI instructions to prevent rounding, the extra digits would be dropped, leaving you with an inexact result.