Supported RPG Features

The TRUNCNBR keyword on CTL-OPT (or H-spec) controls how fixed-format arithmetic opcodes handle numeric overflow.

Value Behavior
*YES (default) Silently truncate high-order digits when a result overflows the target field
*NO Throw a runtime error (RpgDecimalOverflowException) on overflow

The default is *YES. Fixed-format opcodes affected by this setting: Z-ADD, Z-SUB, ADD, SUB, MULT, DIV, MVR, SQRT.

EVAL expressions always throw on overflow regardless of TRUNCNBR.

     H TRUNCNBR(*YES)
     D Big             S              5P 0 INZ(99999)
     D Small           S              3P 0
      * Z-ADD overflow: 99999 → 3P0 silently truncates to 999
     C                   Z-ADD     Big           Small