The MULTIPLY statement multiplies numeric items and sets the values of data items equal to the results.
Format 1: MULTIPLY statement >>-MULTIPLY--+-identifier-1-+--BY-------------------------------> '-literal-1----' .---------------------------. V | >----identifier-2--+---------+-+--------------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+--------------+-------------------------------------------->< '-END-MULTIPLY-'
In format 1, the value of identifier-1 or literal-1 is multiplied by the value of identifier-2; the product is then placed in identifier-2. For each successive occurrence of identifier-2, the multiplication takes place in the left-to-right order in which identifier-2 is specified.
Format 2: MULTIPLY statement with GIVING phrase >>-MULTIPLY--+-identifier-1-+--BY--+-identifier-2-+-------------> '-literal-1----' '-literal-2----' .---------------------------. V | >--GIVING----identifier-3--+---------+-+------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+--------------+-------------------------------------------->< '-END-MULTIPLY-'
In format 2, the value of identifier-1 or literal-1 is multiplied by the value of identifier-2 or literal-2. The product is then stored in the data items referenced by identifier-3.
For all formats:
For format-2:
identifier-3, the GIVING phrase identifier, is the only identifier in the MULTIPLY statement that can be a date field.
If identifier-3 names a date field, see Storing arithmetic results that involve date fields for details on how the product is stored in identifier-3.
Floating-point data items and literals can be used anywhere a numeric data item or literal can be specified.
When the ARITH(COMPAT) compiler option is in effect, the composite of operands can contain a maximum of 30 digits. When the ARITH(EXTEND) compiler option is in effect, the composite of operands can contain a maximum of 31 digits. For more information, see Arithmetic statement operands and the details on arithmetic intermediate results in the Enterprise COBOL Programming Guide.
This explicit scope terminator serves to delimit the scope of the MULTIPLY statement. END-MULTIPLY permits a conditional MULTIPLY statement to be nested in another conditional statement. END-MULTIPLY can also be used with an imperative MULTIPLY statement.
For more information, see Delimited scope statements.