Propeller Manual

Table Of Contents
Operators – Spin Language Reference
Table 2-9: Math and Logic Operators
Constant Expressions
1
Operator
Assignment
Usage
Integer Float
Is
Unary
Description, Page Number
=
always n/a
1
n/a
1
Constant assignment (CON blocks only), 148
:=
always n/a
1
n/a
1
Variable assignment (PUB/PRI blocks only), 149
+ +=
9 9
Add, 149
+
never
9 9 9
Positive (+X); unary form of Add, 150
- -=
9 9
Subtract, 150
-
if solo
9 9 9
Negate (-X); unary form of Subtract, 150
--
always
9
Pre-decrement (--X) or post-decrement (X--), 151
++
always
9
Pre-increment (++X) or post-increment (X++), 152
* *=
9 9
Multiply and return lower 32 bits (signed), 153
** **=
9
Multiply and return upper 32 bits (signed), 153
/ /=
9 9
Divide (signed), 154
// //=
9
Modulus (signed), 154
#> #>=
9 9
Limit minimum (signed), 155
<# <#=
9 9
Limit maximum (signed), 155
^^
if solo
9 9 9
Square root, 156
||
if solo
9 9 9
Absolute value, 156
~
always
9
Sign-extend from bit 7 (~X) or post-clear to 0 (X~); all bits low, 156
~~
always
9
Sign-extend from bit 15 (~~X) or post-set to -1 (X~~); all bits high, 157
~> ~>=
9
Shift arithmetic right, 158
?
always
9
Random number forward (?X) or reverse (X?), 159
|<
if solo
9
9
Bitwise: Decode value (0 - 31) into single-high-bit long, 160
>|
if solo
9
9
Bitwise: Encode long into value (0 - 32) as high-bit priority, 160
<< <<=
9
Bitwise: Shift left, 161
>> >>=
9
Bitwise: Shift right, 161
<- <-=
9
Bitwise: Rotate left, 162
-> ->=
9
Bitwise: Rotate right, 162
>< ><=
9
Bitwise: Reverse, 163
& &=
9
Bitwise: AND, 164
| |=
9
Bitwise: OR, 165
^ ^=
9
Bitwise: XOR, 165
!
if solo
9
9
Bitwise: NOT, 166
AND AND=
9 9
Boolean: AND (promotes non-0 to -1), 167
OR OR=
9 9
Boolean: OR (promotes non-0 to -1), 168
NOT
if solo
9 9 9
Boolean: NOT (promotes non-0 to -1), 168
== ===
9 9
Boolean: Is equal, 169
<> <>=
9 9
Boolean: Is not equal, 170
< <=
9 9
Boolean: Is less than (signed), 171
> >=
9 9
Boolean: Is greater than (signed), 171
=< =<=
9 9
Boolean: Is equal or less (signed), 171
=> =>=
9 9
Boolean: Is equal or greater (signed), 172
@
never
9
9
Symbol address, 173
@@
never
9
Object address plus symbol, 173
1
Assignment forms of operators are not allowed in constant expressions.
.
Page 144 · Propeller Manual v1.1