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.
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 the same, 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
.