The DIVIDE statement divides one numeric data item into or by one or more others, and stores the result in the quotient and remainder.
DIVIDE Statement - Format 1 - INTO >>-DIVIDE--+-identifier-1-+--INTO-------------------------------> '-literal-1----' .---------------------------. V | >----identifier-2--+---------+-+--------------------------------> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+------------+---------------------------------------------->< '-END-DIVIDE-'
In Format 1, the value of identifier-1 or literal-1 is divided into the value of identifier-2; the quotient is then placed in identifier-2. This process is repeated for each successive occurrence of identifier-2.
DIVIDE Statement - Format 2 - INTO GIVING >>-DIVIDE--+-identifier-1-+--INTO--+-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-DIVIDE-'
In Format 2, the value of identifier-1 or literal-1 is divided into the value of identifier-2 or literal-2. The value of the quotient is stored in each data item referenced by identifier-3.
DIVIDE Statement - Format 3 - BY GIVING >>-DIVIDE--+-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-DIVIDE-'
In Format 3, the value of identifier-1 or literal-1 is divided by the value of identifier-2 or literal-2. This quotient is stored in each data item referenced by identifier-3.
DIVIDE Statement - Format 4 - INTO GIVING REMAINDER >>-DIVIDE--+-identifier-1-+--INTO--+-identifier-2-+-------------> '-literal-1----' '-literal-2----' >--GIVING--identifier-3--+---------+--REMAINDER--identifier-4---> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+------------+---------------------------------------------->< '-END-DIVIDE-'
In Format 4, the value of identifier-1 or literal-1 is divided into identifier-2 or literal-2. This quotient is stored in identifier-3, and the value of the remainder is stored in identifier-4.
DIVIDE Statement - Format 5 - BY GIVING REMAINDER >>-DIVIDE--+-identifier-1-+--BY--+-identifier-2-+---------------> '-literal-1----' '-literal-2----' >--GIVING--identifier-3--+---------+--REMAINDER--identifier-4---> '-ROUNDED-' >--+--------------------------------------------+---------------> '-+----+--SIZE ERROR--imperative-statement-1-' '-ON-' >--+-------------------------------------------------+----------> '-NOT--+----+--SIZE ERROR--imperative-statement-2-' '-ON-' >--+------------+---------------------------------------------->< '-END-DIVIDE-'
In Format 5, the value of identifier-1 or literal-1 is divided by identifier-2 or literal-2. This quotient is stored in identifier-3, and the value of the remainder is stored in identifier-4.
The composite of operands is determined by superimposing all of the receiving data items, excluding the REMAINDER data item. For more information on the composite of operands, see the Size of Operands.
In Formats 1 through 3, floating-point data items and literals can be used anywhere that a numeric data item or literal can be specified.
In Formats 4 and 5, floating-point data items or literals cannot be used.