Operator usage – Rockwell Automation 5370-CMPK Color CVIM Module MATH-PAK User Manual
Page 36
Chapter 4
Defining Formulas
4–21
Operator Usage
The MATH-PAK operators generally fall into one of four categories –
mathematical, statistical, logical, and conditional (refer to Table 4.D,
beginning on page 4–18, for a brief description of the operator types, which
are listed according to category). The operators are discussed in the
following sections, according to category.
Mathematical Operators
This section discusses the mathematical operators, which include the
arithmetic operators, trigonometric operators, inverse trigonometric
operators, and other operators.
Arithmetic operators: + – /
*
+ (addition)
–
Adds the two operands on either side of the “+”
– (subtraction)
–
Subtracts the operand on the right of the “–” from the
operand on the left.
/ (division) –
Divides the operand on the left of the “/” by the
operand on the right.
*
(multiplication) – Multiplies the two operands on either side of the “
*
”
Format / Usage: In general, enter and use the arithmetic operators in
formulas just as you would in writing an arithmetic equation – use two
operands with an operator, placing the arithmetic operator in the formula
between the two operands, as shown in the example below:
GAGE1 * GAGE2
Multiply operator placed between two operands
Arithmetic hierarchy of execution: In general, arithmetic operations are
executed from left to right, with multiplication and division operators
evaluated before either addition or subtraction, as in general practice.
Example usage: This formula averages the results from gages 1 and 2. The
formula first uses the add operator (+) to add the 2 gage operands (because
the parentheses prioritize the add operation), then uses the divide operator
( / ) to divide the result of the add operation by the constant, 2:
(GAGE1 + GAGE2) / 2