2-157
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Math Instructions
2
SUB (-)
When you calculate real numbers, use the CheckReal instruction (page 2-209) to see if Out is positive
infinity, negative infinity, or nonnumeric data.
• Set the data type of Out to include the valid ranges of In1 and In2.
• If In1, In2, and Out are integers, make sure the subtraction result will fit in the valid range of Out. Oth-
erwise, the value of Out will be an illegal value. An error will not occur.
• If either In1 or In2 is a real number and the addition result will not fit in the valid range of Out, the
value of Out will be positive or negative infinity.
• The results for underflows in subtraction are different for ladder diagrams and ST. In a ladder dia-
gram, the calculation is performed within the range of the data type of the input variables. In ST, the
precision of the numbers is increased to perform the calculation.
• Subtraction results of positive or negative infinity are handled as follows for real number values.
• If any of the values of In1 to InN is nonnumeric data, the value of Out is nonnumeric data.
• You can subtract a real number from an integer or an integer from a real number. If you do, Out is a
real number.
Additional Information
Precautions for Correct Use
Subtraction
Subtraction
result
+∞ minus number +∞
Number minus +∞−∞
−∞
minus number −∞
Number minus −∞ +∞
+∞
minus +∞
Nonnumeric
data
+∞ minus −∞ +∞
−∞
minus +∞−∞
−∞
minus −∞
Nonnumeric
data