Datasheet
Propeller™ P8X32A Datasheet www.parallax.com
Copyright © Parallax Inc. Page 18 of 37 Rev 1.1 9/12/2008
6.2. Math and Logic Operators
Table 17: Math and Logic Operators
Operator
Constant
Expressions
3
Level
1
Normal Assign
2
Integer Float
Is Unary Description
--
always
9
Pre-decrement (--X) or post-decrement (X--).
++
always
9
Pre-increment (++X) or post-increment (X++).
~
always
9
Sign-extend bit 7 (~X) or post-clear to 0 (X~).
~~
always
9
Sign-extend bit 15 (~~X) or post-set to -1 (X~~).
?
always
9
Random number forward (?X) or reverse (X?).
@
never
9
9
Symbol address.
Highest
(0)
@@
never
9
Object address plus symbol.
+
never
9 9 9
Positive (+X); unary form of Add.
-
if solo
9 9 9
Negate (-X); unary form of Subtract.
^^
if solo
9 9 9
Square root.
||
if solo
9 9 9
Absolute value.
|<
if solo
9
9
Bitwise: Decode 0 – 31 to long w/single-high-bit.
>|
if solo
9
9
Bitwise: Encode long to 0 – 32; high-bit priority.
1
!
if solo
9
9
Bitwise: NOT.
<- <-=
9
Bitwise: Rotate left.
-> ->=
9
Bitwise: Rotate right.
<< <<=
9
Bitwise: Shift left.
>> >>=
9
Bitwise: Shift right.
~> ~>=
9
Shift arithmetic right.
2
>< ><=
9
Bitwise: Reverse.
3
& &=
9
Bitwise: AND.
| |=
9
Bitwise: OR.
4
^ ^=
9
Bitwise: XOR.
* *=
9 9
Multiply and return lower 32 bits (signed).
** **=
9
Multiply and return upper 32 bits (signed).
/ /=
9 9
Divide (signed).
5
// //=
9
Modulus (signed).
+ +=
9 9
Add.
6
- -=
9 9
Subtract.
#> #>=
9 9
Limit minimum (signed).
7
<# <#=
9 9
Limit maximum (signed).
< <=
9 9
Boolean: Is less than (signed).
> >=
9 9
Boolean: Is greater than (signed).
<> <>=
9 9
Boolean: Is not equal.
== ===
9 9
Boolean: Is equal.
=< =<=
9 9
Boolean: Is equal or less (signed).
8
=> =>=
9 9
Boolean: Is equal or greater (signed).
9
NOT
if solo
9 9 9
Boolean: NOT (promotes non-0 to -1).
10
AND AND=
9 9
Boolean: AND (promotes non-0 to -1).
11
OR OR=
9 9
Boolean: OR (promotes non-0 to -1).
=
always n/a
3
n/a
3
Constant assignment (CON blocks).
Lowest
(12)
:=
always n/a
3
n/a
3
Variable assignment (PUB/PRI blocks).
1
Precedence level: higher-level operators evaluate before lower-level operators. Operators in same level are commutable; evaluation order does not matter.
2
Assignment forms of binary (non-unary) operators are in the lowest precedence (level 12).
3
Assignment forms of operators are not allowed in constant expressions.