Propeller Manual

Table Of Contents
2: Spin Language Reference – Operators
Table 2-10: Operator Precedence Levels
Level Notes Operators Operator Names
Highest (0) Unary
--, ++, ~, ~~, ?, @, @@
Inc/Decrement, Clear, Set, Random, Symbol/Object Address
1 Unary
+, -, ^^, ||, |<, >|, !
Positive, Negate, Square Root, Absolute, Decode, Encode, Bitwise NOT
2
->, <-, >>, <<, ~>, ><
Rotate Right/Left, Shift Right/Left, Shift Arithmetic Right, Reverse
3
&
Bitwise AND
4
|, ^
Bitwise OR, Bitwise XOR
5
*, **, /, //
Multiply-Low, Multiply-High, Divide, Modulus
6
+, -
Add, Subtract
7
#>, <#
Limit Minimum/Maximum
8
<, >, <>, ==, =<, =>
Boolean: Less/Greater Than, Not Equal, Equal, Equal or Less/Greater
9 Unary
NOT
Boolean NOT
10
AND
Boolean AND
11
OR
Boolean OR
Lowest (12) =, :=, all other assignments Constant/Variable Assignment, assignment forms of Binary Operators
Unary / Binary
Each operator is either unary or binary in nature. Unary operators are those that operate on
only one operand. For example:
!Flag ' bitwise NOT of Flag
^^Total ' square root of Total
Binary operators are those that operate on two operands. For example:
X + Y ' add X and Y
Num << 4 ' shift Num left 4 bits
Note that the term “binary operator” means “two operands,” and has nothing to do with
binary digits. To distinguish operators whose function relates to binary digits, we’ll use the
term “bitwise” instead.
Normal / Assignment
Normal operators, like Add ‘
+’ and Shift Left ‘<<’, operate on their operand(s) and provide
the result for use by the rest of the expression, without affecting the operand or operands
themselves. Those that are assignment operators, however, write their result to either the
variable they operated on (unary), or to the variable to their immediate left (binary), in
addition to providing the result for use by the rest of the expression.
Propeller Manual v1.1 · Page 145