HOSTARITHMETIC

Controls whether or not decimal truncation of arithmetic results occurs following a size error condition.
Note: This directive is supported for native COBOL only.

Syntax:

>>-.---.-.----.--HOSTARITHMETIC----------------><
   +-/-+ +-NO-+

Parameters:

None

Properties:

Default: NOHOSTARITHMETIC
Phase: Syntax check
$SET: Yes

Comments:

The effect of specifying HOSTARITHMETIC is as follows:

  • If the result of an arithmetic operation (ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE) with no ON SIZE ERROR clause exceeds the maximum value that the target item can hold, decimal truncation will be performed on the result, provided that:
    • The target item is a decimal type, that is DISPLAY, COMP-3 or COMP-6
    • None of the source items are floating-point items
    • No exponentiation or intrinsic functions are used in the calculation
    • Neither the composite of operands nor any intermediate result has more than 31 decimal digits
  • If the result of an arithmetic operation (ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE) with an ON SIZE ERROR clause exceeds the maximum value that the target item can hold, the ON SIZE ERROR clause will be executed as normal, and the value of the target item will not be altered.

If you specify this directive in a $SET statement it will affect the run-time behavior of the whole program regardless of where it is placed.

Important: This directive can adversely affect the performance of generated code.