The SUBTRACT Statement
The SUBTRACT statement is used to subtract one, or the sum of two or more,
numeric data items from one or more items, and set the values of one or more
items equal to the results.
General Formats



Syntax Rules
- Each identifier must refer to a numeric elementary item, except that in Format
2 each identifier following the word GIVING must refer to either an elementary
numeric item or an elementary numeric edited item, and in Format 3 each identifier
must refer to a group item.
-
The composite of
operands is determined as follows (see the topic Arithmetic Statements
in the chapter Procedure Division):
- In Format 1, by using all of the operands in a given statement.
- In Format 2, by using all of the operands in a given statement excluding
the data items that follow the word GIVING.
- In Format 3, separately for each pair of corresponding data items.
- Each literal must be a numeric literal.


Floating-point data items and literals can be used anywhere numeric data
items and literals can be specified.
- CORR is an abbreviation for CORRESPONDING.
General Rules
- See the topics The ROUNDED Phrase, The ON SIZE ERROR Phrase, Arithmetic
Statements, Overlapping Operands and Multiple Results In Arithmetic
Statements in the chapter Procedure Division.

The COBOL system ensures enough places are carried so as not to lose significant
digits during execution.
- All literals or identifiers preceding the word FROM are added together and
this total is subtracted from the current value of identifier-2 storing the
result immediately into identifier-2, and repeating this process respectively
for each operand following the word FROM.
- In Format 2, all literals or identifiers preceding the word FROM are added
together, the sum is subtracted from literal-2 or identifier-2 and the result
of the subtraction is stored as the new value of each data item referenced
by identifier-3.
- If Format 3 is used, data items in identifier-1 are subtracted from and stored
into corresponding data items in identifier-2.