Subtract Numeric (SUBN)


Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand [4-7]
SUBN 1047
Difference Minuend Subtrahend


SUBNR 1247
Difference Minuend Subtrahend


SUBNB 1C47 Branch options Difference Minuend Subtrahend Branch targets


SUBNBR 1E47 Branch options Difference Minuend Subtrahend Branch targets


SUBNI 1847 Indicator options Difference Minuend Subtrahend Indicator targets


SUBNIR 1A47 Indicator options Difference Minuend Subtrahend Indicator targets
Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3: Numeric scalar.

Operand 4-7:

Short forms


Op Code (Hex) Extender Operand 1 Operand 2 Operand [3-6]
SUBNS 1147
Difference/Minuend Subtrahend


SUBNSR 1347
Difference/Minuend Subtrahend


SUBNBS 1D47 Branch options Difference/Minuend Subtrahend Branch targets


SUBNBSR 1F47 Branch options Difference/Minuend Subtrahend Branch targets


SUBNIS 1947 Indicator options Difference/Minuend Subtrahend Indicator targets


SUBNISR 1B47 Indicator options Difference/Minuend Subtrahend Indicator targets
Operand 1: Numeric variable scalar.

Operand 2: Numeric scalar.

Operand 3-6:

Caution  If operands overlap but do not share all of the same bytes, results of operations performed on these operands are not predictable. If overlapped operands share all of the same bytes, the results are predictable when direct addressing is used or whenever the assume coincident operand overlap attribute has been specified in the program template. If the assume coincident operand overlap attribute has not been specified in the program template and indirect addressing is used (that is, based operands, parameters, strings with variable lengths, and arrays with variable subscripts), the results are not always predictable.

Description  The difference is the result of subtracting the subtrahend from the minuend.

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

Source operands are the minuend and subtrahend. The receiver operand is the difference.

If operands have different types, source operands, minuend and subtrahend, 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.

Minuend and subtrahend are subtracted according to their type. Floating point operands are subtracted using floating point subtraction. Packed decimal operands are subtracted using packed decimal subtraction. Unsigned binary subtraction is used with unsigned binary operands. Signed binary operands are subtracted using two's complement binary subtraction.

Better performance can be obtained if all operands have the same type. Signed and unsigned binary subtractions execute faster than either packed decimal or floating point subtractions.

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

For a decimal operation, alignment of the assumed decimal point takes place by padding with 0's on the right end of the source operand with lesser precision.

Floating-point subtraction uses exponent comparison and significand subtraction. Alignment of the binary point is performed, if necessary, by shifting the significand of the value with the smaller exponent to the right. The exponent is increased by one for each binary digit shifted until the two exponents agree.

The operation uses the length and the precision of the source and receiver operands to calculate accurate results. Operations performed in decimal are limited to 31 decimal digits in the intermediate result.

The subtract operation is performed according to the rules of algebra.

The result of the operation is copied into the difference 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 difference operand, aligned at the assumed decimal point of the difference operand, or both before being copied to it. For fixed-point operation, if significant digits are truncated on the left end of the resultant value, a size  (hex 0C0A) exception is signaled.

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

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

For a floating-point difference operand, if the exponent of the resultant value is either too large or too small to be represented in the difference field, the floating-point overflow  (hex 0C06) exception or the floating-point underflow  (hex 0C07) 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.

Size exceptions can be inhibited.

Resultant Conditions 

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