Propeller Manual

Table Of Contents
Operators – Spin Language Reference
Add has an assignment form, +=, that uses the variable to its left as both the first operand and
the result destination.
For example:
X += 10 'Short form of X := X + 10
Here, the value of X is added to 10 and the result is stored back in X. The assignment form of
Add may also be used within expressions for intermediate results; see Intermediate
Assignments, page 147.
Positive ‘
+’ (unary form of Add)
Positive is the unary form of Add and can be used similar to Negate except that it is never an
assignment operator. Positive is essentially ignored by the compiler, but is handy when the
sign of operands is important to emphasize. For example:
Val := +2 - A
Subtract ‘-’, ‘-=
The Subtract operator subtracts two values. Subtract can be used in both variable and
constant expressions. Example:
X := Y - 5
Subtract has an assignment form, -=, that uses the variable to its left as both the first operand
and the result destination. For example,
X -= 10 'Short form of X := X - 10
Here, 10 is subtracted from the value of X and the result is stored back in X. The assignment
form of subtract may also be used within expressions for intermediate results; see
Intermediate Assignments, page 147.
Negate ‘
-’ (unary form of Subtract)
Negate is the unary form of Subtract. Negate toggles the sign of the value on its right; a
positive value becomes negative and a negative value becomes positive. For example:
Val := -2 + A
Negate becomes an assignment operator when it is the sole operator to the left of a variable
on a line by itself. For example:
-A
Page 150 · Propeller Manual v1.1