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:
|
|
|
|
|
|
|
|
|
|
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:
The result is placed in the last operand specified {dest} and the other operands always remain unchanged.
If format 2 is specified, the value in {source2} is moved into {dest} then {source1} is divided into {dest}.
If a source operand is equal to zero, the OVER Condition Flag is set. The destination variable is determined as follows:
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.
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.
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.
If
the source operand is an INTEGER variable and the destination variable
is an INTEGER, the destination variable is set to a zero value.
If
the source operand is a FORM variable and the destination variable is
an INTEGER, the destination variable is set to a zero value.
The EQUAL (or ZERO), OVER, and LESS Condition Flags are applicable.
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.
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.
This operation supports the mixing of variable types (FORM and INTEGER).
Enhanced Array processing is supported.
See Also: Example Code, CALC, MOVE, Mathematical Instructions
![]() |