Divide (DIV)

Instruction Syntax

Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand [4-7]
DIV 104F Quotient Dividend Divisor
DIVR 124F Quotient Dividend Divisor
DIVI 184F Indicator options Quotient Dividend Divisor Indicator targets
DIVIR 1A4F Indicator options Quotient Dividend Divisor Indicator targets
DIVB 1C4F Branch options Quotient Dividend Divisor Branch targets
DIVBR 1E4F Branch options Quotient Dividend Divisor Branch targets

Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3: Numeric scalar.

Operand 4-7:

  • Branch Form–Branch point, instruction pointer, relative instruction number, or absolute instruction number.
  • Indicator Form–Numeric variable scalar or character variable scalar.

Short forms

Op Code (Hex) Extender Operand 1 Operand 2 Operand [3-6]
DIVS 114F Quotient/Dividend Divisor
DIVSR 134F Quotient/Dividend Divisor
DIVIS 194F Indicator options Quotient/Dividend Divisor Indicator targets
DIVISR 1B4F Indicator options Quotient/Dividend Divisor Indicator targets
DIVBS 1D4F Branch options Quotient/Dividend Divisor Branch targets
DIVBSR 1F4F Branch options Quotient/Dividend Divisor Branch targets

Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3-6:

  • Branch Form–Branch point, instruction pointer, relative instruction number, or absolute instruction number.
  • Indicator Form–Numeric variable scalar or character variable scalar.

Description:

The quotient is the result of dividing the dividend by the divisor.

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

Source operands are the dividend and divisor. The receiver operand is the quotient.

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 floating point type, source operands are converted to floating point type.
  2. Otherwise, if any one of the operands has zoned or packed decimal type, source operands are converted to packed decimal.
  3. 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. Floating point operands are divided using floating point division. 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 either packed decimal or floating point division.

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

Decimal operands used in floating-point operations cannot contain more than 15 total digit positions.

If the divisor has a numeric value of zero, a zero divide (hex 0C0B) exception or floating-point zero divide (hex 0C0E) exception is signaled respectively for fixed-point versus floating-point operations. If the dividend has a value of zero, the result of the division is a zero quotient value.

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.

Floating-point division uses exponent subtraction and significand division.

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

For fixed-point computations and for the significand division of a floating-point computation, the division operation is performed according to the rules of algebra. Unsigned binary is treated as a positive number for the algebra.

For a floating-point computation, the operation is performed as if to infinite precision.

The 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 for 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.

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

For the optional round form of the instruction, specification of a floating-point receiver operand is invalid.

For fixed-point operations in programs that request to be notified of size (hex 0C0A) exceptions, if nonzero digits are truncated from the left end of the resultant value, a size (hex 0C0A) exception is signaled.

For floating-point operations that involve a fixed-point receiver field, if nonzero digits would be truncated from the left end of the resultant value, an invalid floating-point conversion (hex 0C0C) exception is signaled.

For a floating-point quotient operand, if the exponent of the resultant value is either too large or too small to be represented in the quotient field, the floating-point overflow (hex 0C06) exception and floating-point underflow (hex 0C07) exception are signaled, respectively.

Resultant Conditions

  • Positive–The algebraic value of the numeric scalar quotient is positive.
  • Negative–The algebraic value of the numeric scalar quotient is negative.
  • Zero–The algebraic value of the numeric scalar quotient is zero.
  • Unordered–The value assigned a floating-point quotient operand is NaN.

Authorization Required

  • None

Lock Enforcement

  • None

Exceptions

  • 06 Addressing
    • 0601 Space Addressing Violation
    • 0602 Boundary Alignment
    • 0603 Range
  • 08 Argument/Parameter
    • 0801 Parameter Reference Violation
  • 0C Computation
    • 0C02 Decimal Data
    • 0C06 Floating-Point Overflow
    • 0C07 Floating-Point Underflow
    • 0C09 Floating-Point Invalid Operand
    • 0C0A Size
    • 0C0B Zero Divide
    • 0C0C Invalid Floating-Point Conversion
    • 0C0D Floating-Point Inexact Result
    • 0C0E Floating-Point Zero Divide
  • 10 Damage Encountered
    • 1004 System Object Damage State
    • 1044 Partial System Object Damage
  • 1C Machine-Dependent
    • 1C03 Machine Storage Limit Exceeded
  • 20 Machine Support
    • 2002 Machine Check
    • 2003 Function Check
  • 22 Object Access
    • 2201 Object Not Found
    • 2202 Object Destroyed
    • 2203 Object Suspended
    • 2208 Object Compressed
    • 220B Object Not Available
  • 24 Pointer Specification
    • 2401 Pointer Does Not Exist
    • 2402 Pointer Type Invalid
  • 2C Program Execution
    • 2C04 Branch Target Invalid
  • 2E Resource Control Limit
    • 2E01 User Profile Storage Limit Exceeded
  • 36 Space Management
    • 3601 Space Extension/Truncation
  • 44 Protection Violation
    • 4401 Object Domain or Hardware Storage Protection Violation
    • 4402 Literal Values Cannot Be Changed