Operators
Operators are symbols used to compare or assign values.
Comparison operators
- ==
- Checks if the two values are equal. Don't confuse this with the assignment operator, which is a single equal sign.
- !=
- Checks if the two values are not equal.
- >
- Checks if the lefthand value is greater than the righthand value.
- <
- Checks if the lefthand value is less than the righthand value.
- >=
- Checks if the lefthand value is greater than or equal to the righthand value.
- <=
- Checks if the lefthand value is less than or equal to the righthand value.
Numbers and timers can be compared to each other. All variables can only be compared
with variables of the same type, and they only support equality and inequality
comparisons (==
and !=
).
Assignment operators
Expressions are not supported in this language; however, compound operations are
available. For example, a += b
is equivalent to the hypothetical statement
a = a + b
.
- =
- Assign. Sets the variable on the lefthand side to the value on the righthand side. Don't confuse this with the equality comparison operator, which is two equal signs.
- +=
- Add-assign. Increases the variable on the lefthand side by the value on the righthand side.
- -=
- Subtract-assign. Decreases the variable on the lefthand side by the value on the righthand side.
- *=
- Multiply-assign. Multiplies the variable on the lefthand side by the value on the righthand side.
- /=
- Divide-assign. Divides the variable on the lefthand side by the value on the righthand side. Any remainder will be discarded.
- %=
- Modulo-assign. Sets the lefthand variable to the remainder of dividing the lefthand value by the righthand value.
- &=
- Binary-AND-assign. Modifies each bit in the variable on the lefthand side: bits will be set to zero if the corresponding bit in the righthand value is zero; otherwise, bits will be left unchanged.
- |=
- Binary-OR-assign. Modifies each bit in the variable on the lefthand side: bits will be set to one if the corresponding bit in the righthand value is one; otherwise, bits will be left unchanged.
- ^=
- Binary-XOR-assign. Modifies each bit in the variable on the lefthand side: bits will be set to one if the corresponding bit in the righthand value is different, or set to zero otherwise.
- ~=
- Binary-NOT-assign. Modifies each bit in the variable on the lefthand
side: bits will be set to zero if the corresponding bit in the righthand value is
one, or left unchanged otherwise. This is equivalent to
a &= ~b
. - <<=
- Binary left shift. Shifts the bits of the lefthand operand to the left; the righthand operand controls the number of bits to shift by.
- >>=
- Arithmetic right shift. Shifts the bits of the lefthand operand to the right; the righthand operand controls the number of bits to shift by. If the lefthand operand is negative, its sign bit is extended.
- lhs = abs(rhs)
- Absolute value assignment. Sets the lefthand variable to the absolute value of the righthand value.
Numbers and timers can be assigned to each other, and can use any assignment operator. All
other variables can only be assigned values of the same type, and can't use any operators
other than =
.