Divide with Remainder (DIVREM)


Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand 4 Operand [5-7]
DIVREM 1074
Quotient Dividend Divisor Remainder


DIVREMR 1274
Quotient Dividend Divisor Remainder


DIVREMI 1874 Indicator options Quotient Dividend Divisor Remainder Indicator targets


DIVREMIR 1A74 Indicator options Quotient Dividend Divisor Remainder Indicator targets


DIVREMB 1C74 Branch options Quotient Dividend Divisor Remainder Branch targets


DIVREMBR 1E74 Branch options Quotient Dividend Divisor Remainder Branch targets

Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3: Numeric scalar.

Operand 4: Numeric variable scalar.

Operand 5-7:


Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand [4-6]
DIVREMS 1174
Quotient/Dividend Divisor Remainder


DIVREMSR 1374
Quotient/Dividend Divisor Remainder


DIVREMIS 1974 Indicator options Quotient/Dividend Divisor Remainder Indicator targets


DIVREMISR 1B74 Indicator options Quotient/Dividend Divisor Remainder Indicator targets


DIVREMBS 1D74 Branch options Quotient/Dividend Divisor Remainder Branch targets


DIVREMBSR 1F74 Branch options Quotient/Dividend Divisor Remainder Branch targets

Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3: Numeric variable scalar.

Operand 4-6:

Description  The quotient is the result of dividing the dividend by the divisor. The remainder is the dividend minus the product of the divisor and quotient.

Operands can have packed or zoned decimal, signed or unsigned binary type.

Source operands are the dividend and divisor. The receiver operands are the quotient and remainder.

If operands are not of the same type, source operands are converted according to the following rules:

  1. If any one of the operands has zoned or packed decimal type, source operands are converted to packed decimal.

  2. Otherwise, the binary operands are converted to a like type. Note: unsigned binary(2) scalars are logically treated as signed binary(4) scalars.

Source operands are divided according to their type. Packed decimal operands are divided using packed decimal division. Unsigned binary division is used with unsigned source operands. Signed binary operands are divided using two's complement binary division.

Better performance can be obtained if all operands have the same type. Signed and unsigned binary division execute faster than packed decimal division.

The operands must be numeric with any implicit conversions occurring according to the rules for arithmetic operations as outlined in Arithmetic Operations.

Floating-point is not supported for this instruction.

If the divisor operand has a numeric value of 0, a zero divide  (hex 0C0B) exception is signaled. If the dividend operand has a value of 0, the result of the division is a zero value quotient and remainder.

For a decimal operation, the precision of the result of the divide operation is determined by the number of fractional digit positions specified for the quotient. In other words, the divide operation will be performed so as to calculate a resultant quotient of the same precision as that specified for the quotient operand. If necessary, internal alignment of the assumed decimal point for the dividend and divisor operands is performed to ensure the correct precision for the resultant quotient value. These internal alignments are not subject to detection of the decimal point alignment exception. An internal quotient value will be calculated for any combination of decimal attributes which may be specified for the instruction's operands. However, the assignment of the result to the quotient operand is subject to detection of the size  (hex 0C0A) exception thereby limiting the assignment to, at most, the rightmost 31 digits of the calculated result.

If the dividend operand is shorter than the divisor operand, it is logically adjusted to the length of the divisor operand.

The division operation is performed according to the rules of algebra. Unsigned binary is treated as a positive number for the algebra. The quotient result of the operation is copied into the quotient operand. If this operand is not the same type as that used in performing the operation, the resultant value is converted to its type. If necessary, the resultant value is adjusted to the length of the quotient operand, aligned at the assumed decimal point of the quotient operand, or both before being copied to it. Length adjustment and decimal point alignment are performed according to the rules of arithmetic operations as outlined in Arithmetic Operations. If significant digits are truncated on the left end of the resultant value, a size  (hex 0C0A) exception is signaled.

After the quotient numeric value has been determined, the numeric value of the remainder operand is calculated as follows:

Remainder = Dividend - (Quotient*Divisor)
If the optional round form of this instruction is being used, the rounding applies to the quotient but not the remainder. The quotient value used to calculate the remainder is the resultant value of the division. The resultant value of the calculation is copied into the remainder operand. The sign of the remainder is the same as that of the dividend operand unless the remainder has a value of 0, in which case its sign is positive. If the remainder operand is not the same type as that used in performing the operation, the resultant value is converted to its type. If necessary, the resultant value is adjusted to the length of the remainder operand, aligned at the assumed decimal point of the remainder operand, or both before being copied to it. Length adjustment and decimal point alignment are performed according to the rules of arithmetic operations as outlined in the Arithmetic Operations. If significant digits are truncated off the left end of the resultant value, a size  (hex 0C0A) exception is signaled.

If a decimal to binary conversion causes a size  (hex 0C0A) exception to be signaled (in programs that request size exceptions to be signaled), the binary value contains the correct truncated result only if the decimal value contains 15 or fewer significant nonfractional digits.

Resultant Conditions

The algebraic value of the numeric scalar quotient is

Authorization Required

Lock Enforcement

Exceptions

06 Addressing

08 Argument/Parameter

0C Computation

10 Damage Encountered

1C Machine-Dependent

20 Machine Support

22 Object Access

24 Pointer Specification

2C Program Execution

2E Resource Control Limit

36 Space Management

44 Protection Violation