COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-42
COMPUTE
expression
is an arithmetic expression.
imp-stmt-1
is an imperative statement to be executed when a size error has been detected in
the computation or in storing the result.
imp-stmt-2
is an imperative statement to be executed when no size error is detected in the
computation or in storing the result.
END-COMPUTE
ends the scope of the COMPUTE statement, causing the COMPUTE to be a
delimited-scope statement. If the COMPUTE statement does not end with an END-
COMPUTE phrase, the presence of the SIZE ERROR or the NOT SIZE ERROR
phrase causes the COMPUTE statement to be a conditional statement, which ends
at the next period separator.
Usage Considerations:
•
See Arithmetic Operations for information on data conversion and alignment,
intermediate results, multiple results, and incompatible data.
•
See Arithmetic Precision for information on precision of addition.
•
See ROUNDED Phrase and SIZE ERROR Phrase for information on these
phrases.
For Example 9-9 and Example 9-10, these descriptions are in the Working-Storage
Section of a program:
Example 9-9. COMPUTE Statement (page 1 of 2)
WORKING-STORAGE SECTION.
01 COMPUTE-RESULT PIC 999 VALUE ZEROS.
01 DIAGNOSTIC-FIELD PIC X(35).
01 WS-RESULT PIC S9(9) VALUE ZEROS.
01 WS-99 PIC S99 VALUE 99.
01 WS-FIVE-ONES PIC S9(5) VALUE 11111.
01 EXPONENT PIC 9(5) VALUE ZERO COMP.
01 A PIC 9(4)V99.
01 B PIC 9(4)V99 VALUE 8.
01 C PIC 9(4)V99 VALUE 5.
01 U PIC 9(4)V99 VALUE 7.
01 X PIC 9V99.