DIVIDE


ANSI

 

The DIVIDE instruction (which may be abbreviated as DIV) divides the contents of the first operand into the contents of the second operand can, optionally, place the result in a third operand. It uses one of the following formats:

 

(1)

[label]

DIVIDE

{source}{sep}{dest}

(2)

[label]

DIVIDE

{source1}{sep}{source2}{sep2}{dest}

 

Where:

label

Optional. A Program Execution Label.

source

Required. A Numeric Variable, numeric Literal, or Expression that is divided into the {dest} variable.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

dest

Required. A Numeric Variable into which the {source} variable is divided.

source1

Required. A Numeric Variable, numeric Literal, or Expression that is moved to the destination variable before the {source1} variable is applied.

sep2

Required. A comma or the keyword GIVING.

source2

Required. A Numeric Variable that is moved to {dest} before the {source1} is divided into {dest}.

Flags Affected: LESS, OVER, ZERO

Note the following:

  1. The result is placed in the last operand specified {dest} and the other operands always remain unchanged.

  2. If format 2 is specified, the value in {source2} is moved into {dest} then {source1} is divided into {dest}.

  3. If a source operand is equal to zero, the OVER Condition Flag is set. The destination variable is determined as follows:

  4. Generate/bullet1.gif    If the source operand is an INTEGER and the destination variable is a FORM, the destination variable is set to the largest number possible by filling the variable with all '9' numeric characters.

    Generate/bullet1.gif    If the source operand is a FORM variable without a decimal point and the destination variable is a FORM, the destination variable is set to the largest number possible by filling the variable with all '9' numeric characters.

    Generate/bullet1.gif    If the source operand is a FORM variable with a decimal point and the destination variable is a FORM, the destination variable is set to a zero value.

    Generate/bullet1.gif    If the source operand is an INTEGER variable and the destination variable is an INTEGER, the destination variable is set to a zero value.

    Generate/bullet1.gif    If the source operand is a FORM variable and the destination variable is an INTEGER, the destination variable is set to a zero value.

  5. The EQUAL (or ZERO), OVER, and LESS Condition Flags are applicable.

  6. The rounding and truncation rules described in the section on Numeric Variables normally apply. However, truncation but not rounding, applies if a source operand is an INTEGER.

  7. If the environment variable PLB_ROUND is present, the result is rounded in accordance with the ANSI PL/B specification. Otherwise, the source operand is aligned and rounded to the destination operand's format.

  8. This operation supports the mixing of variable types (FORM and INTEGER).

  9. Enhanced Array processing is supported.

 

 

See Also: Example Code, CALC, MOVE, Mathematical Instructions

 



PL/B Language Reference DECR EXP