Sunday, 11 August 2013

COBOL TRUNC Compiler Option.

When using the TRUNC(BIN) compiler option, all binary (COMP) sending fields are treated as either halfword, fullword, or doubleword values, depending on the PICTURE clause, and code is generated to truncate all binary receiving fields to the corresponding halfword, fullword, or doubleword boundary (base 2 truncation). The full content of the field is significant.
This can add a significant amount of degradation since typically some data conversions must be done, which may require the use of some library subroutines. BIN is usually the slowest of the three sub options for TRUNC.
When using the TRUNC(STD) compiler option, the final intermediate result of an arithmetic expression, or the sending field in the MOVE statement, is truncated to the number of digits in the PICTURE clause of the binary (COMP) receiving field (base 10 truncation).
This can add a significant amount of degradation since typically the number is divided by some power of ten (depending on the number of digits in the PICTURE clause) and the remainder is used; a divide instruction is one of the more expensive instructions. TRUNC(STD) behaves in a similar way as TRUNC in OS/VS COBOL.
However, with TRUNC(OPT), the compiler assumes that the data conforms to the PICTURE and USAGE specifications and manipulates the result based on the size of the field in storage (halfword, fullword or doubleword).
 Although TRUNC(OPT) most closely resembles the behavior of NOTRUNC in OS/VS COBOL and is recommended for compatibility with NOTRUNC, there are some cases where the result will  be different.
Please consult the COBOL Migration Guide and Programming Guide for additional details.
TRUNC(STD) conforms to the ANSI and SAA standards, whereas TRUNC(BIN) and TRUNC(OPT) do not.
TRUNC(OPT) is provided as a performance tuning option and should be used only when the data in the application program conforms to the PICTURE and USAGE specifications.
For performance sensitive applications, the use of TRUNC(OPT) is recommended when possible.

Created with Artisteer

No comments:

Post a Comment

New In-feed ads