The MULTIPLY Statement
Syntax
Format 1
MULTIPLY { identifier-1
literal-1 } ... BY {identifier-2 [ROUNDED]} ...
[ON SIZE ERROR imperative-statement-1]
[NOT ON SIZE ERROR imperative-statement-2]
[END-MULTIPLY]
Format 2
MULTIPLY { identifier-1
literal-1 } ... BY { identifier-2
literal-2 } GIVING {identifier-3 [ROUNDED]}...
[ON SIZE ERROR imperative-statement-1]
[NOT ON SIZE ERROR imperative-statement-2]
[END-MULTIPLY]
Description
The MULTIPLY statement is used to multiply numeric items together. Both formats work slightly differently and each is described in the correspondingly numbered area.
1. The first format is used to multiply a field or value by another field or value. The product of the field(s) or value(s) listed between MULTIPLY andBY is computed and multiplied by the value of the field(s) following the BY. The answer is stored in the individual field. For example, in MULTIPLY A BY B, the value in A is multiplied by the value in B and the result is stored in B. The value in A is unchanged. Furthermore, in MULTIPLY C BY D E, the value in C is multiplied by the value in D, storing the answer in D and the value of C is also multiplied by E, storing the value in F. The value in C is unchanged.
2. The second format is used by multiply field(s) or value(s) by one another field or value, storing the answer in a different field. The field(s) or value(s) listed between MULTIPLY and GIVING are multiplied and stored in the field(s) following the GIVING. For example, in MULTIPLY A BY B GIVING C, the value in A is multiplied by the value in B and the result is stored in C. The values in A and B are unchanged.
Tips
1. The fields to be multiplied must have numeric pictures, that is, they can only have the characters 9, S, and V in their PIC clauses.
2. Receiving fields may be either numeric or numeric edited fields.
3. Use the SIZE ERROR clause to detect field overflow on the receiving field.
4. In both formats, the mathematically correct results are computed, but if the receiving field is too short in either the integer or decimal portion,the result will be truncated, the integer on the left and the decimal on the right. Including the ROUNDED phrase will result the answer field being rounded instead of truncating. Rounding is always done in the least significant portion of the answer
Syntax
Format 1
MULTIPLY { identifier-1
literal-1 } ... BY {identifier-2 [ROUNDED]} ...
[ON SIZE ERROR imperative-statement-1]
[NOT ON SIZE ERROR imperative-statement-2]
[END-MULTIPLY]
Format 2
MULTIPLY { identifier-1
literal-1 } ... BY { identifier-2
literal-2 } GIVING {identifier-3 [ROUNDED]}...
[ON SIZE ERROR imperative-statement-1]
[NOT ON SIZE ERROR imperative-statement-2]
[END-MULTIPLY]
Description
The MULTIPLY statement is used to multiply numeric items together. Both formats work slightly differently and each is described in the correspondingly numbered area.
1. The first format is used to multiply a field or value by another field or value. The product of the field(s) or value(s) listed between MULTIPLY andBY is computed and multiplied by the value of the field(s) following the BY. The answer is stored in the individual field. For example, in MULTIPLY A BY B, the value in A is multiplied by the value in B and the result is stored in B. The value in A is unchanged. Furthermore, in MULTIPLY C BY D E, the value in C is multiplied by the value in D, storing the answer in D and the value of C is also multiplied by E, storing the value in F. The value in C is unchanged.
2. The second format is used by multiply field(s) or value(s) by one another field or value, storing the answer in a different field. The field(s) or value(s) listed between MULTIPLY and GIVING are multiplied and stored in the field(s) following the GIVING. For example, in MULTIPLY A BY B GIVING C, the value in A is multiplied by the value in B and the result is stored in C. The values in A and B are unchanged.
Tips
1. The fields to be multiplied must have numeric pictures, that is, they can only have the characters 9, S, and V in their PIC clauses.
2. Receiving fields may be either numeric or numeric edited fields.
3. Use the SIZE ERROR clause to detect field overflow on the receiving field.
4. In both formats, the mathematically correct results are computed, but if the receiving field is too short in either the integer or decimal portion,the result will be truncated, the integer on the left and the decimal on the right. Including the ROUNDED phrase will result the answer field being rounded instead of truncating. Rounding is always done in the least significant portion of the answer