BASIC Moves Development Studio
06/2005
Danaher Motion
22 Rev
E
M-SS-005-03l
Bit-Wise Logical Operator
Symbol
Unary/Binary
Operand Type
Bitwise Negation
BNot
Unary
long
Bitwise And
BAnd
Binary
long
Bitwise Or
BOr
Binary
long
Bitwise Xor
BXor
Binary
long
Shift Left
SHL
Binary
long
Shift Right
SHR
Binary
long
Negation is simply placing a minus sign in front of a constant or variable to
invert its arithmetic sign. Modulo division produces the remainder of an
addition. For example,
82 Mod 5
is equal to
2
(the remainder of 82/5). If the
first operand is negative, the resultant value is negative (-2). The sign of the
result is determined by the sign of the first operand, and the sign of the
second operand has no effect.
The relative precedence of exponentiation and negation may seem
somewhat counter-intuitive. The following examples illustrate the actual
behavior.
Common shared D as double
D = -1
? D^2
1
? -1^2
-1
In the second section of the above example, exponentiation is performed first
then negation is performed.
Common shared D as double
D = -1
? D = -1
1
In the example above, the “=” sign is taken as a relational operator (i.e., Is D
= -1?) The relation is True, or 1.
? D^2 = -1^2
0
In the example above, the “=” sign is taken as a relational operator, (i.e.,
Is D^2 = -1^2?). Again, the exponentiation is performed first, and then the
relation is evaluated as False, or 0.
The "+" operator, when used with strings, performs concatenation of strings.
In points, “+” (addition) and “-“ (subtraction) operators can be used between
points of the same type and size, or between a point and a long or double
type scalar. On the other hand, “*” (multiplication) and “/” (division) operators
can only be operated between a point and double or long scalar, but not
between two points.
In Logical operations, every value that is not 0 is assumed true and set to 1.
And-ing combines two values so the result is true (1) if both values are true
(that is, non-zero). Or-ing combines them so the result is true (1) if either
value is true. Exclusive-Or produces true if one or the other value is true. It
produces false (0) if both or neither are true. Before logical operations begin,
all operands are converted to 1 (true) or 0 (false). The rule is that everything
that is not 0 becomes 1.