There are three types of operators that can be used in programs:
Calculation Operators
Calculation Operator
In the table below, the calculation result assumes variable A
is 3 (0000 0000 0000 0011), and the variable B
is 4 (0000 0000 0000 0100).
Remainder calculation and all Bitwise calculations will be performed with 32-bit integer data.
Operator | Function | Example | Description |
| Bitwise invert |
| Each bit of A (0000 0000 0000 0011b) is inverted. The result is 1111 1111 1111 1100b. |
| Addition |
| Adds A and B. The result is 7. |
| Subtraction |
| Subtracts B from A. The result is -1. |
| Multiplication |
| Multiplies A and B. The result is 12. |
| Division |
| Divides A with B. The result is 0.75. |
| Remainder |
| Indicates the remainder from the division of A with B. The result is 3. |
| Bitwise AND |
| Bitwise logical AND calculation of A and B. The result is 0. |
| Bitwise OR |
| Bitwise logical OR calculation of A and B. The result is 0111b (= 7). |
| Bitwise XOR |
| Bitwise logical XOR calculation of A and B. The result is 0111b (= 7). |
| Bitwise Shift Left |
| Shifts the bits of A to the left as much as B. The rightmost part is filled with 0. The result is 0011 0000b (= 48). |
| Bitwise Shift Right |
| Shifts the bits of A to the right as much as B. The leftmost part is filled with 0. The result is 0. |
Logical/Comparative Operator
In the table shown below, the calculation result assumes that variable A
is 1 (True) and variable B
is 0 (False). In Canvas, the values other than 0 are all processed as True. Only 0 is recognized as False.
When the calculation result is true, the result is always 1.
Operator | Function | Example | Description |
| Logical AND |
| If value in variables |
| Logical OR |
| If value in variables |
| Less than |
| If A is smaller than B, the result is 1. In other cases, the result is 0. |
| Greater than |
| If A is greater than B, the result is 1. In other cases, the result is 0. |
| Less than or equal to |
| If A is smaller than or equal to B, the result is 1. In other cases, the result is 0. |
| Greater than or equal to |
| If A is greater than or equal to B, the result is 1. In other cases, the result is 0. |
| Equal to |
| If A is equal to B, the result is 1. In other cases, the result is 0. |
| Is not equal to |
| If A is not B, the result is 1. In other cases, the result is 0. |
Other Operator
Operator | Function | Example | Description |
| Store |
| Stores the value in variable |
The Store (=) operator can be used consecutively.
A = B = C;
In this case, the value of A and B will be set as C. In other words, the value at the rightmost side of the operator will be treated as the result value of the “=” operation. The example mentioned above will be processed internally in the program as shown below.
B ← C
A ← B