Compile-time arithmetic expressions
You can specify a compile-time arithmetic expression in the DEFINE and EVALUATE directives and as part of a constant conditional expression, such as those found in IF directives or WHEN phrases of the EVALUATE directives.
Note: In this topic,
"literals" also include compilation
variables, which means that you can use compilation variables in compile-time
arithmetic expressions.
A compile-time arithmetic expression
follows the usual arithmetic expression rules, with the following
exceptions:
- The exponentiation operator shall not be specified.
- All operands shall be integer numeric literals or arithmetic expressions in which all operands are integer numeric literals.
- The expression shall be specified in such a way that a division by zero does not occur.
- Intermediate results are computed according to the rules described in Fixed-point data and intermediate results. For that purpose, the integer operands of compile-time arithmetic expressions can be considered fixed-point numbers with 0 decimal digits. The ARITH(COMPAT|EXTEND|FULL) option setting is taken into account when deciding how many digits of precision to maintain for intermediate results.