| Addition |
a + b
a += b |
Integers, floats |
|
2 + 5 == 7 |
| Subtraction |
a - b
a -= b |
Integers, floats |
|
2 - 5 == -3 |
| Negation |
-a |
Integers, floats |
|
-1 == 0 - 1 |
| Multiplication |
a \* b
a \*= b |
Integers, floats |
|
2 \* 5 == 10 |
| Division |
a / b
a /= b |
Integers, floats |
|
10 / 5 == 2 |
| Remainder of division |
a % b
a %= b |
Integers |
|
10 % 3 == 1 |
| Bit shift left |
a \<\< b
a \<\<= b |
Integers |
b must be unsigned. |
0b1 \<\< 8 == 0b100000000 |
| Bit shift right |
a >> b
a >>= b |
Integers |
Arithmetic shift right if a is signed, otherwise logical shift right. b must be unsigned. |
0b1010 >> 1 == 0b101 |
| Bitwise AND |
a & b
a &= b |
Integers |
|
0b011 & 0b101 == 0b001 |
| Bitwise OR |
a | b
a |= b |
Integers |
|
0b010 | 0b100 == 0b110 |
| Bitwise XOR |
a ^ b
a ^= b |
Integers |
|
0b011 ^ 0b101 == 0b110 |
| Bitwise NOT |
\~a |
Fixed-width integers |
|
\~@as(u8, 0b10101111) == 0b01010000 |
| Logical AND |
a and b |
bool |
If a is false, returns false without evaluating b. Otherwise, returns b. |
(false and true) == false |
| Logical OR |
a or b |
bool |
If a is true, returns true without evaluating b. Otherwise, returns b. |
(false or true) == true |
| Logical NOT |
!a |
bool |
|
!false == true |
| Equality |
a == b |
Integers, floats, bool, enum, direction, comptime\_string, color, control\_task\_id, data\_task\_id, input\_queue, local\_task\_id, output\_queue, ut\_id, type |
|
(1 == 1) == true |
| Inequality |
a != b |
Integers, floats, bool, enum, direction, comptime\_string, color, control\_task\_id, data\_task\_id, input\_queue, local\_task\_id, output\_queue, ut\_id, type |
|
(1 != 1) == false |
| Greater than |
a > b |
Integers, floats |
|
(2 > 1) == true |
| Greater than or equal |
a >= b |
Integers, floats |
|
(2 >= 1) == true |
| Less than |
a \< b |
Integers, floats |
|
(1 \< 2) == true |
| Less than or equal |
a \<= b |
Integers, floats |
|
(1 \<= 2) == true |