8.2
Arithmetic functions
Admissible data types
Argument: UINT, UDINT, REAL (only REAL for negation, only UINT or UDINT for modulo)
Result: UINT, UDINT, REAL
Addition
Addition is an expandable function. The sum of the arguments is returned as the result.
Example:
OUT := IN1 + IN2 + ... INn;
Subtraction
The second argument is subtracted from the first argument as a result.
Example:
OUT := IN1 - IN2;
Multiplication
Multiplication is an expandable function. The result is obtained by multiplying the arguments.
Example:
OUT := IN1 * IN2 * ...INn;
Division
The quotient of the two arguments is returned as the result.
The result of the division of integers (UINT or UDINT) is an integer with truncation of the decimal places
(example: 7/3 = 2).
Example:
OUT := IN1 / IN2;
Negation
REAL numbers can be negated.
Example:
OUT := -IN;
Modulo
The arguments of the modulo function (%) must be integers (UINT or UDINT). The result is the remainder
from the division of both numbers (example: 17/3 = 5, remainder 2).
Example:
OUT := IN1 % IN2;
8 Functions
37