DECIMAL

The DECIMAL option specifies how the compiler should handle certain FIXED DECIMAL operations and assignments.

Read syntax diagramSkip visual syntax diagram
               .-,--------------------.      
               V   .-FOFLONASGN---.   |      
>>-DECIMAL--(----+-+-NOFOFLONASGN-+-+-+--)---------------------><
                 | .-NOFOFLONMULT-. |        
                 +-+-FOFLONMULT---+-+        
                 | .-NOFORCEDSIGN-. |        
                 +-+-FORCEDSIGN---+-+        
                 | .-NOTRUNCFLOAT-. |        
                 '-+-TRUNCFLOAT---+-'        

FOFLONASGN
When the FOFLONASGN option is enabled and the SIZE condition is disabled, the FOFLONASGN option requires the compiler to generate code that will raise the FIXEDOVERFLOW condition whenever a FIXED DECIMAL expression is assigned to a FIXED DECIMAL target and significant digits are lost.

Conversely, under the NOFOFLONASGN option, the compiler will generate code that will not raise the FIXEDOVERFLOW condition when significant digits are lost in such an assignment.

For example, given a variable A declared as FIXED DEC(5), the assignment A = A + 1 might raise FOFL under the FOFLONASGN option, but will never raise FOFL under the NOFOFLONASGN option.

Note, however, that under the NOFOFLONASGN option, the FIXEDOVERFLOW condition can still be raised by operations that produce a result with more digits than allowed by the FIXEDDEC suboption of the LIMITS option. For example, given a variable B declared as FIXED DEC(15) with the value 999_999_999_999_999 and given that the FIXEDDEC suboption of the LIMITS specifies the maximum precision as 15, then the assignment B = B + 1 will raise the FIXEDOVERFLOW condition (if FOFL is enabled).

FOFLONMULT
The FOFLONMULT option requires the compiler to generate code that will raise the FIXEDOVERFLOW condition for any use of the MULTIPLY built-in function that will produce a FIXED DEC result that is too large for the precision specified in the built-in function.

Conversely, under the NOFOFLONMULT option, the compiler will generate code that will produce a truncated result for any such use of the MULTIPLY built-in function.

Note that the use of the FOFLONMULT option changes the default language semantics (which is to truncate a too large result of the MULTIPLY built-in function applied to FIXED DEC - unless the SIZE condition is enabled).

FORCEDSIGN
The FORCEDSIGN option will force the compiler to generate extra code to ensure that whenever a FIXED DECIMAL result with the value zero is generated, the sign nibble of the result will have the value ’C’X. This option can cause the compiler to generate code that will perform much, much worse than the code generated under the NOFORCEDSIGN suboption.

Also, when this option is in effect, more data exceptions might occur when you run your code. For example, if you assign one FIXED DEC(5) variable to another FIXED DEC(5) variable, the compiler would normally generate an MVC instruction to perform the move. However, if the FORCEDSIGN option is in effect, to ensure that the result has the preferred sign, the compiler will generate a ZAP instruction to perform the move. If the source contains invalid packed decimal data, the ZAP instruction, but not the MVC instruction, will raise a decimal data exception.

Under this option, data exceptions might also be raised when one PICTURE variable is assigned to another PICTURE variable because that conversion usually involves an implicit conversion to FIXED DEC, which, under this option, will generate a ZAP instruction that will raise a data exception if the source contains invalid data.

Under DECIMAL(NOFORCEDSIGN), a "negative zero" might be produced by certain calculations. However, a programmer should rely on getting a negative zero only when assigning a negative literal to a FIXED DEC that cannot hold a value of that small a magnitude (such as assigning -.001 to a FIXED DEC(5,2)).

TRUNCFLOAT
This suboption instructs the compiler how to handle assignments of float to fixed decimal when truncation might occur.

Under TRUNCFLOAT, if a hexadecimal float value is converted to FIXED DEC(p,q) where p <=18 and abs(q) <= p, and if the source value is too large for the target, the source value will be truncated and overflow will not be raised.

The default is NOTRUNCFLOAT.