The INTPREC keyword on CTL-OPT (or H-spec) specifies the decimal precision of integer and unsigned intermediate values in binary arithmetic operations (+, -, *, /) within expressions.
| Value | Meaning |
|---|---|
INTPREC(10) |
10-digit precision for integer/unsigned intermediates (default) |
INTPREC(20) |
20-digit precision - prevents high-order truncation in large integer arithmetic |
If at least one operand is an 8-byte integer or unsigned field (INT(20) / UNS(20)), the result always uses 20-digit precision regardless of INTPREC.
CTL-OPT INTPREC(20);
DCL-S A INT(10) INZ(100000);
DCL-S B INT(10) INZ(100000);
DCL-S Result PACKED(15:0);
Result = A * B;
DSPLY %CHAR(Result); // → 10000000000
Fixed-format example:
H INTPREC(20)
D A S 10I 0 INZ(100000)
D B S 10I 0 INZ(100000)
D Result S 15P 0
C EVAL Result = A * B
C Result DSPLY