GFK-0467K Chapter 4 Series 90-30/20/Micro Instructions Set 4-29
4
Math Functions and Data Types
Function Operation Displays as
ADD INT Q(16 bit) = I1(16 bit) + I2(16 bit) 5-digit base 10 number with sign
ADD DINT Q(32 bit) = I1(32 bit) + I2(32 bit) 8-digit base 10 number with sign
ADD REAL* Q(32 bit) = I1(32 bit) + I2(32 bit) 7-digit base 10 number, sign and decimal
SUB INT Q(16 bit) = I1(16 bit) – I2(16 bit) 5-digit base 10 number with sign
SUB DINT Q(32 bit) = I1(32 bit) – I2(32 bit) 8-digit base 10 number with sign
SUB REAL* Q(32 bit) = I1(32 bit) – I2(32 bit) 7-digit base 10 number, sign and decimal
MUL INT Q(16 bit) = I1(16 bit) * I2(16 bit) 5-digit base 10 number with sign
MUL DINT Q(32 bit) = I1(32 bit) * I2(32 bit) 8-digit base 10 number with sign
MUL REAL* Q(32 bit) = I1(32 bit) * I2(32 bit) 7-digit base 10 number, sign and decimal
DIV INT Q(16 bit) = I1(16 bit) / I2(16 bit) 5-digit base 10 number with sign
DIV DINT Q(32 bit) = I1(32 bit) / I2(32 bit) 8-digit base 10 number with sign
DIV REAL* Q(32 bit) = I1(32 bit) / I2(32 bit) 7-digit base 10 number, sign and decimal
* 350 and 360 series CPUs only, Release 9 or later, or all releases of CPU352
Note
The input and output data types must be the same. The MUL and DIV functions
do not support a mixed mode as the 90-70 PLCs do. For example, the MUL INT
of 2 16-bit inputs produces a 16-bit product, not a 32-bit product. Using MUL
DINT for a 32-bit product requires both inputs to be 32-bit. The DIV INT
divides a 16-bit I2 for a 16-bit result while DIV DINT divides a 32-bit I1 by 32-
bit I2 for a 32-bit result.
These functions pass power if there is no math overflow. If an overflow occurs,
the result is the largest value with the proper sign and no power flow.
Be careful to avoid overflows when using MUL and DIV functions. If you have to convert INT to
DINT values, remember that the CPU uses standard 2’s complement with the sign extended to the
highest bit of the second word. You must check the sign of the low 16-bit word and extend it into
the second 16 bit word. If the most significant bit in a 16-bit INT word is 0 (positive), move a 0 to
the second word. If the most significant bit in a 16-bit word is –1 (negative), move a –1 or hex
0FFFFh to the second word. Converting from DINT to INT is easier as the low 16-bit word (first
register) is the INT part of a DINT 32-bit word. The upper 16 bits or second word should be either
a 0 (positive) or –1 (negative) value or the DINT number is too big to convert to 16 bit.