FIXEDOVERFLOW condition

A computational condition indicating that the length of a FIXED DECIMAL result exceeds the maximum allowable length.

Enabled/Disabled status

Always enabled.

Result

Undefined unless no FIXEDOVERFLOW ON unit is present, in which case it is raised to ERROR.

Raised

When the result exceeds the maximum allowed by the computer/implementation. This is controlled by the -fdmaxp compiler option.

FIXEDOVERFLOW is also raised for built-in functions where the intermediate result of the specified P,Q arguments exceeds the user-specified P,Q.

Restrictions

  • No support for NOFIXEDOVERFLOW prefix condition.
  • No support for -prefix NOFIXEDOVERFLOW.
  • ONCONDID() values, when queried from an ON ERROR, reflect the underlying condition, such as FIXEDOVERFLOW or SIZE and not ERROR.
  • Open PL/I does not match the mainframe PL/I "undefined behavior" for operations that trigger FIXEDOVERFLOW upon the assignment to a FIXED DECIMAL variable.
  • If you choose to mix or match procedures compiled with -decimal forceodd (default) with -decimal noforceodd within the same application, then you must take it upon yourself to ensure that the data for every FIXED DECIMAL variable declared with an even precision is correctly marshalled.
    Important: We strongly recommend that you not declare any FIXED DECIMAL variable with an even precision.

Notes

Emulated FIXED DECIMAL operations
The hardware upon which Open PL/I runs does not support PACKED operations, and FIXED DECIMAL operations are emulated through a combination of generated code and library calls. Where it is possible, Open PL/I detects and raises the FIXEDOVERFLOW condition when the results of an assignment and/or expression is such that an overflow of the FIXED DECIMAL variable or intermediate expression precision has occurred.
FIXED DECIMAL variables
For FIXED DECIMAL variables that specify an even precision, the default behavior as of Enterprise Developer 8.0 Patch Update 2 is use the extra high order nibble even though the defined precision does not indicate that this is strictly necessary.
Note: To revert to the behavior of Enterprise Developer 7.0 and earlier, specify the -decimal noforceodd compiler directive.
Difference in Behavior vs. Mainframe PL/I
  • If a program has variables initialized such that the result causes FIXEDOVERFLOW, then mainframe PL/I generates an S-level diagnostic and creates no object code. Enterprise Developer generates an E-level diagnostic, and does create object code. The created programs immediately trigger a FIXEDOVERFLOW upon entering the prologue code for the routine. You can use the compiler message exit to change this behavior to an S-level diagnostic.
IBM discrepancies between defined and actual FIXEDOVERFLOW behavior
The following table describes certain behaviors documented in the IBM Language Reference Manual (LRM) that actually behave differently than documented. For each entry, the actual IBM behavior and the behavior in Enterprise Developer are clarified.
Behavior according to the IBM LRM Actual IBM behavior Enterprise Developer behavior
The MAXVAL() and PRECVAL() built-in functions for a FIXED DECIMAL variable (or expression) reflect the true state of a variable with an even precision. The MAXVAL() and PRECVAL() built-in functions for a FIXED DECIMAL variable (or expression) do not reflect the true state of a variable with an even precision. For example, if you were to declare a FIXED DECIMAL(4,0) variable and assign it the value from a FIXED BIN(31) that contains a value between 10000 and 99999, the variable when referenced does have your assigned value; however, MAXVAL returns 9999, and PRECVAL returns 4. Matches the actual IBM behavior.
The MULTIPLY built-in function, generates two FIXEDOVERFLOW conditions - one for the MULTIPLY, and one for the assignment (FOFLONASGN). See Example 1 below. The MULTIPLY built-in function, generates just one FIXEDOVERFLOW condition. Matches the IBM LRM.
A native add of two FIXED DECIMAL variables with equal P,Q values generates FIXEDOVERFLOW when run under z/OS. See Example 2 below. A native add of two FIXED DECIMAL variables with equal P,Q values does not generate FIXEDOVERVLOW when run under z/OS. Matches the IBM LRM.
The BINARY built-in function raises FIXEDOVERFLOW when the first argument is an expression intended to raise it. See Example 3 below. The BINARY built-in function does not raise FIXEDOVERFLOW when the first argument is an expression intended to raise it unless you omit the P,Q arguments. Matches the IBM LRM.
Raises FIXEDOVERFLOW for the FIXED built-in function when the expression argument is intended to raise it. See Example 4 below. Does not raise FIXEDOVERFLOW for the FIXED built-in function when the expression argument is intended to raise it. Matches the IBM LRM.
Raises FIXEDOVERFLOW for the FIXEDBIN built-in function when the expression argument is intended to raise it. See Example 5 below. Does not raise FIXEDOVERFLOW for the FIXEDBIN built-in function when the expression argument is intended to raise it, and gives an incorrect result. Does not raise FIXEDOVERFLOW in this scenario, but gives a correct result.
Raises FIXEDOVERFLOW for the PRECISION built-in function when the expression argument is intended to raise it. See Example 6 below. Does not FIXEDOVERFLOW for the PRECISION built-in function when the expression argument is intended to raise it. Matches the IBM LRM.
For the conversion of a FIXED DECIMAL(4,0) variable to a FIXED BIN(31) on assignment, the maximum value is equivalent to a FIXED BIN(14). See IBM 5.3 LRM, page 76, table 35. For the conversion of a FIXED DECIMAL(4,0) variable to a FIXED BIN(31) on assignment, the maximum value is actually equivalent to a FIXED BIN(31). Matches the actual IBM behavior.

Examples

The following examples illustrate the scenarios described in the IBM discrepancies between defined and actual FIXEDOVERFLOW behavior section above:

Example 1
DCL DEC1 DEC FIXED(5,2) init(999);
DCL DEC2 DEC FIXED(5,2) init(112);
DCL DEC3 DEC FIXED(5,2);
/* 111888 - result overflows 7,2 giving 11888 */
/* 11888 - intermediate result overflows 5,2 on assignment */
/* IBM only generates 1 FIXEDOVERFLOW contradicting what */
/* LRM and Programming guide state for FOFLONASGN and FOFLONMULT */

DEC3 = MULTIPLY(DEC1, DEC2, 7, 2);
Example 2
    DCL DEC1 DEC FIXED(4,2);
  DCL DEC2 DEC FIXED(4,2);
  DCL DEC3 DEC FIXED(7,2);
  dcl TOOBIG DEC FIXED(5,2) init(999);

  DEC1 = 1;
  DEC2 = TOOBIG; /* shouldn't be possible - demonstrates IBM behavior */
  put skip data(dec2);
  put skip list('hex(dec2): ' || hex(dec2));
  dec3 = DEC1 + DEC2;  /* We generate FIXEDOVERFLOW - IBM DOES NOT */
  put skip list('hex(dec3): ' || hex(dec3));
Example 3
    DCL DEC1 DEC FIXED(5,2) init(1);
    DCL DEC2 DEC FIXED(5,2) init(999);
    DCL BIN1 FIXED BIN(31);

    BIN1 = BINARY(DEC1 + DEC2, 3, 0);  /* IBM 
does not generate FIXEDOVERFLOW */
Example 4
    DCL DEC1 DEC FIXED(7,2);
    DCL BIN1 FIXED BIN(31) init(998);     

    DEC1 = FIXED(BIN1 + 2.5, 5, 2);
Example 5
    DCL DEC1 DEC FIXED(7,2) init(998.5);
    DCL BIN1 FIXED BIN(31); 
     
    BIN1 = FIXEDBIN(DEC1 + 2.5, 3, 0);
Example 6
    DCL DEC1 DEC FIXED(7,2);
    DCL BIN1 FIXED BIN(31) init(998); 
     
    DEC1 = PRECISION(BIN1 + 2.5, 5, 2);

Other Information

Abbreviation
FOFL
Condition code
310
Implicit action
Prints a message and raises the ERROR condition.
Normal return
Control is returned to the point immediately after the point at which the condition was raised.