COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-264
SUBTRACT FROM
imperative-stmt-2
is an imperative statement to be executed when no size error is detected in the
subtraction or in storing the result.
END-SUBTRACT
ends the scope of the SUBTRACT statement, causing the SUBTRACT to be a
delimited-scope statement. If the SUBTRACT statement does not end with an
END-SUBTRACT phrase, the presence of the SIZE ERROR or the NOT SIZE
ERROR phrase causes the SUBTRACT statement to be a conditional statement,
which ends at the next period separator.
Usage Considerations:
Mathematics
The values of all the subtrahend s are totaled. That sum is subtracted from each
result, and the result of each such subtraction is then stored after rounding, if
ROUNDED was specified as the new value of the minuend-result. For
example, the statement
SUBTRACT A B C FROM D E
means store D - (A + B + C) in D and store E - (A + B + C) in E.
Specifying the Same Data Item for More Than One Result
If more than one minuend-result specifies the same data item, the final value
of that item reflects multiple subtractions of the intermediate sum. For example,
SUBTRACT A FROM B B
means the final value of B is (B - A) - A.
Operand Identification
For each minuend-result, the process of operand identification occurs just prior
to the “subtract and store” operation; therefore, in
SUBTRACT A, B, C FROM I, I, X(I)
the subscript is not evaluated until the sum of A, B, and C is subtracted twice from
I.
Arithmetic Operations
See Arithmetic Operations for information on data conversion and alignment,
intermediate results, multiple results (and subscript evaluation), and incompatible
data.