Danaher Motion
06/2005
BASIC Moves Development Studio
M-SS-005-03 Rev
E
21
The value of the expression (6.33 * 2.79) is converted from double to long
when the value (17) is copied into I. In the conversion to long, the number is
truncated to the integer portion of the floating-point value.
Logical expressions
are combinations of data and logical operators. For
example,
X1 And X2
is a logical expression. The data and results of logical
elements are type Long. Double variables are not allowed in logical
expressions. The terms, logical and Boolean are considered
interchangeable.
Logical expressions are evaluated from left to right. They are evaluated only
far enough to determine the result. So, in
A And B And C
, if A is 0 (false),
the result is false without evaluating B or C.
Precedence
dictates which operator is executed first. If two operators
appear in an expression, the operator with higher precedence is executed
first. For example, multiplication has a higher precedence than addition. The
expression
1+2*3
is evaluated as
7 ((2 * 3) + 1)
, not
9 ((2 + 1) * 3)
.
The minus sign in the math operators’ table (below) is sometimes confusing
since it shows up twice in the table: once with a high precedence (unary
negation) and once with low precedence subtraction (binary minus). This
difference in precedence is intuitive:
5 * -6
only makes sense if the
negation is executed first.
The tables that follow list different types of operators. The entries in the
tables are listed in order of precedence: the higher in the table, the higher the
operator precedence. Also, the tables themselves are arranged in order of
precedence with respect to one another. Math operators have the highest
precedence. So, all math operations are executed before any other type of
operator is executed. Finally, any time you need to change the standard
precedence, use parentheses. Parentheses have the highest precedence of
all.
Algebraic Operator
Symbol
Unary/Binary
Operand Type
Parentheses
( )
NA
double, long, string, joint, location
Exponentiation ^ Binary
double,
long
Negation
-
Unary
double, long, joint, location
Unary Plus
+
Unary
double, long, joint, location
Multiplication
*
Binary
double, long, joint, location
Division
/
Binary
double, long, joint, location
Modulo Mod
Binary
double,
long
Addition
+
Binary
double, long, string, joint, location
Subtraction
-
Binary
double, long, joint, location
Compound : Binary
location
Relational Operator
Symbol
Binary/Unary
Operand Type
Parentheses
( )
Not applicable
double, long, string
Equality
=
Binary
double, long, string
Inequality
<>
Binary
double, long, string
Less than
<
Binary
double, long, string
Greater than
>
Binary
double, long, string
Less than or equal to
<=
Binary
double, long, string
Greater than or equal to
>=
Binary
double, long, string
Word-wise Logical Operator
Symbol
Unary/Binary
Operand Type
And And
Binary
long
Or Or
Binary
long
Exclusive or
Xor
Binary
long
Not Not
Unary
long