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 for Format 1
General Formats for Format 2
General Formats for Format 3
Syntax Rules for All Formats
- 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
- 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.
Syntax Rules for Formats1 and 2
- 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.
Syntax Rules for Format 3
- CORR is an abbreviation for CORRESPONDING.
General Rules for All Formats
- See the topics
The ROUNDED Phrase,
The ON SIZE ERROR Phrase,
Overlapping Operands and
Multiple Results In Arithmetic Statements in the chapter
- The COBOL system ensures enough places are carried so as not to lose significant digits during execution.
General Rules for Format 1
- 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.
General Rules for Format 2
- 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.
General Rules for Format 3
- If Format 3 is used, data items in identifier-1 are subtracted from and stored into corresponding data items in identifier-2.