Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual
Page 34
![background image](/manuals/580318/34/background.png)
5Ć2
expression with a single or double integer variable, the result is
always integer.
Table 5.1 lists the arithmetic operators and their meanings. In
general, you cannot place two arithmetic operators consecutively in
the same expression. The exception is the unary minus and plus
and the exponentiation symbol **. For example, A* -B is valid, and
A/(-B) is valid, but A+*B is not valid.
Table 5.1 Ć Arithmetic Operators
Operator
Example
Meaning
+
A + B
Add B to A
-
A - B
Subtract B from A
*
A *B
Multiply A by B
/
A/B
Divide A by B
**
A**B
Calculate A to the power B
BASIC evaluates expressions according to arithmetic operator
precedence or priority. Each arithmetic operator has a
predetermined position in the hierarchy or importance of operators.
This priority tells BASIC when to evaluate the operator in relation to
the other operators in the same expression. Refer to table 5.2.
Table 5.2 Ć Relative Precedence of Arithmetic Operators
Symbol
Operation
Relative Precedence
()
Parentheses
1 (Highest, evaluated first)
-
Unary minus
2
+
Unary plus
**
Exponentiation
3
*
Multiply
4
/
Divide
+
Add
5 (Lowest, evaluated last)
-
Subtract
Operators shown on the same line have equal precedence. BASIC
evaluates operators of the same precedence level from left to right.
Note that BASIC evaluates A**B**C as (A**B) **C.
In the case of nested parentheses (one set of parentheses within
another), BASIC evaluates the innermost expression first, then the
one immediately outside it, and so on. The evaluation proceeds
from the inside out until all parenthetical expressions have been
evaluated. For example, in the expression B = (25+(16*(9**2))),
(9**2) is the innermost parenthetical expression and BASIC
evaluates it first. Then it calculates (16*81), and finally (25+1296).