COBOL/400 Language Help

Format 5 (DIVIDE BY, GIVING, with REMAINDER)

Description
In Format 5, the value of identifier-1 or literal-1 is divided by identifier-2 or literal-2. The value of the quotient is stored in identifier-3, and the value of the remainder is stored in identifier-4.
Format 5 (DIVIDE BY, GIVING, with REMAINDER)
 
->->--DIVIDE--*--identifier-1--*--BY--*-identifier-2-*-------->
            *--literal-1-----*      *-literal-2----*
 
->--GIVING identifier-3--*-----------*----------------------->
                        *--ROUNDED--*
 
->--REMAINDER identifier-4----------------------------------->
 
->----*----------------------------------------------*------->
     *--*----*---SIZE ERROR imperative-statement-1--*
        *-ON-*
 
->---*---------------------------------------------------*--->
    *-NOT---*----*---SIZE ERROR imperative-statement-2--*
            *-ON-*
 
->--*------------*-------------------------------------------><-
   *-END-DIVIDE-*
 

identifier-1 or -2

Identifier-1 and identifier-2 must name an elementary numeric item.

literal-1 or -2

Literal must be a numeric literal.

identifier-3

Identifier-3 must name an elementary numeric or numeric-edited item.

identifier-3 or identifier-4

Identifier-3 and identifier-4 must name an elementary numeric or numeric-edited item.

ROUNDED

The quotient used to calculate the remainder is in an intermediate field. The value of the intermediate field is truncated rather than rounded.

REMAINDER

The result of subtracting the product of the quotient and the divisor from the dividend is stored in identifier-4. If identifier-3, the quotient, is a numeric-edited item, the quotient used to calculate the remainder is an intermediate field that contains the unedited quotient.

Any subscripts for identifier-4 in the REMAINDER phrase are evaluated after the result of the divide operation is stored in identifier-3 of the GIVING phrase.

SIZE ERROR imperative-statement-1

If a size error occurs in the quotient, no remainder calculation is meaningful. Therefore, the contents of the quotient field (identifier-3) and the remainder field (identifier-4) are unchanged.

If a size error occurs in the remainder, the contents of the remainder field (identifier-4) are unchanged.

In either of these cases, you must analyze the results to determine which situation has actually occurred.

Click here for more information about SIZE ERROR/NOT SIZE ERROR phrases.


[ Top of Page | Previous Page | Next Page | Table of Contents ]