MULTIPLY statement

The MULTIPLY statement multiplies numeric items and sets the values of data items equal to the results.

Format 1: MULTIPLY statement

Read syntax diagramSkip visual syntax diagramMULTIPLYidentifier-1literal-1BYidentifier-2ROUNDEDONSIZE ERRORimperative-statement-1NOTONSIZE ERRORimperative-statement-2END-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

Read syntax diagramSkip visual syntax diagramMULTIPLYidentifier-1literal-1BYidentifier-2literal-2GIVING identifier-3ROUNDED ONSIZE ERRORimperative-statement-1NOTONSIZE ERRORimperative-statement-2END-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:

identifier-1 , identifier-2
Must name an elementary numeric item. identifier-1 and identifier-2 cannot be date fields.
literal-1 , literal-2
Must be a numeric literal.

For format-2:

identifier-3
Must name an elementary numeric or numeric-edited item.

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) or ARITH(FULL) 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, Appendix A. Intermediate results and arithmetic precision in the COBOL for Linux® on x86 Programming Guide.

ROUNDED phrase

For formats 1 and 2, see ROUNDED phrase.

SIZE ERROR phrases

For formats 1 and 2, see SIZE ERROR phrases.

END-MULTIPLY phrase

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.