TRUNC

TRUNC affects the way that binary data is truncated during MOVE and arithmetic operations.

Syntax

Read syntax diagramSkip visual syntax diagramTRUNC=*STDOPTBIN
Default
TRUNC=STD
BIN
Should not be used as an installation default. Specifies that:
  • Output binary fields are truncated only at halfword, fullword, and doubleword boundaries, rather than at PICTURE-clause limits.
  • Sending binary fields are treated as halfwords, fullwords, or doublewords, and no assumption is made that the values are limited to those implied by the PICTURE clause.
  • DISPLAY converts and outputs the full content of binary fields with no truncation to the PICTURE description.
Note: When TRUNC(BIN) and NUMCHECK(BIN) are both in effect and an error message or an abend is generated, if you intend to switch to TRUNC(STD|OPT) later for better performance, you must correct the data; if not, you can turn off NUMCHECK(BIN) to reduce the execution time of the application and avoid an error message or an abend.
OPT
The compiler assumes that the data conforms to PICTURE and USAGE specifications. The compiler manipulates the result based on the size of the field in storage (halfword or fullword).

TRUNC=OPT is recommended, but it should be specified only when data being moved into binary areas does not have a value with high precision than that defined by the binary item PICTURE clause. Otherwise, truncation of high-order digits might occur.

STD
Conforms to the 85 COBOL Standard.

Controls the way arithmetic fields are truncated during MOVE and arithmetic operations. The TRUNC option applies only to binary (COMP) receiving fields in MOVE statements and in arithmetic expressions. When TRUNC=STD is in effect, the final intermediate result of an arithmetic expression, or of the sending field in the MOVE statement, truncates to the number of digits in the PICTURE clause of the binary receiving field.

Performance consideration: Using TRUNC=OPT does not generate additional code, and generally improves performance. However, both TRUNC=BIN and TRUNC=STD generate additional code whenever a BINARY data item is changed. TRUNC=BIN is usually the slower of these options.

Recommendations:
  • TRUNC=BIN is the recommended option for programs that use binary values set by other products. Other products, such as IMS, Db2®, C/C++, FORTRAN, and PL/I, might place values in COBOL binary data items that do not conform to the PICTURE clause of those data items.
  • You can use TRUNC=OPT with CICS® programs provided that your data conforms to the PICTURE clause for the binary data items.
  • Setting this option affects program runtime logic; that is, the same COBOL source program can give different results depending on the option setting. Verify whether your COBOL source programs assume a particular setting for correct running.

Related references  
NUMCHECK