Propeller Manual

Table Of Contents
2: Spin Language Reference – Operators
Propeller Manual v1.1 · Page 169
The above example returns the Boolean opposite of Y; TRUE (-1) if Y is zero, or FALSE (0) if Y
is non-zero. During the comparison, it promotes the value of
Y to -1 if it is non-zero, making
any value, other than 0, a -1, so that the comparison becomes: “If NOT true” or “If NOT
false”
Quite often this operator is used in combination with other comparison operators, such as in
the following example.
IF NOT ( (Y > 9) AND (Y < 21) )
This example evaluates the result of (Y > 9 AND Y < 21), and returns the Boolean opposite of
the result;
TRUE (-1) if Y is in the range 10 to 20, in this case.
Boolean NOT becomes an assignment operator when it is the sole operator to the left of a
variable on a line by itself. For example:
NOT Flag
This would store the Boolean opposite of Flag back into Flag.
Be careful not to get Boolean NOT ‘
NOT’ confused with Bitwise NOT‘T !’. Boolean NOT is
for comparison purposes while Bitwise NOT is for bit manipulation (see page ). 166
Boolean Is Equal ‘
==’, ‘===
The Boolean operator Is Equal compares two operands and returns
TRUE (-1) if both values
are the same, or returns
FALSE (0), otherwise. Is Equal can be used in both variable and
constant expressions. Example:
X := Y == Z
The above example compares the value of Y with the value of Z and sets X to either: TRUE (-1)
if
Y is the same value as Z, or FALSE (0) if Y is not the same value as Z.
This operator is often used in conditional expressions, such as in the following example.
IF (Y == 1)
Here, the Is Equal operator returns TRUE if Y equals 1.
Is Equal has an assignment form,
===, that uses the variable to its left as both the first operand
and the result destination. For example,
X === Y 'Short form of X := X == Y