Page 1 of 1

compiler option

PostPosted: Thu Oct 07, 2010 7:35 am
by kumarshiva
what is the purpose of compiler option TRUNC(OPT)

Re: compiler option

PostPosted: Thu Oct 07, 2010 7:49 am
by Robert Sample
The COBOL Programming Guide says
TRUNC(OPT)
TRUNC(OPT) is a performance option. When TRUNC(OPT) is in effect, the compiler assumes that data conforms to PICTURE specifications in USAGE BINARY receiving fields in MOVE statements and arithmetic expressions. The results are manipulated in the most optimal way, either truncating to the number of digits in the PICTURE clause, or to the size of the binary field in storage (halfword, fullword, or doubleword).

Tips:

* Use the TRUNC(OPT) option only if you are sure that the data being moved into the binary areas will not have a value with larger precision than that defined by the PICTURE clause for the binary item. Otherwise, unpredictable results could occur. This truncation is performed in the most efficient manner possible; therefore, the results are dependent on the particular code sequence generated. It is not possible to predict the truncation without seeing the code sequence generated for a particular statement.

* There are some cases when programs compiled with the TRUNC(OPT) option under Enterprise COBOL could give different results than the same programs compiled under OS/VS COBOL with NOTRUNC. You must actually lose nonzero high-order digits for this difference to appear.
And the real question is, why are you not reading the manual yourself to find this out? A professional career in IT requires the ability to research independently and figure out things on your own -- which means you need to know how to read manuals.

Re: compiler option

PostPosted: Thu Oct 07, 2010 8:13 am
by kumarshiva
Thanks for the response.This is really useful for me.