Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


MULTIPLY statement

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

Format 1
Read syntax diagramSkip visual syntax diagram>>-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
Read syntax diagramSkip visual syntax diagram>>-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:

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) 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 COBOL for Windows 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.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)