Math and Logic Operators Table
Operator | Assignment Usage | Constant Expressions1 | Is Unary | Description | |||
Integer | Float | ||||||
= | always | n/a1 | n/a1 |
| Constant Assignment '=' (CON blocks only) | ||
:= | always | n/a1 | n/a1 |
| Variable Assignment ':=' (PUB/PRI blocks only) | ||
+ | += | ✓ | ✓ |
| |||
+ | never | ✓ | ✓ | ✓ | |||
- | -= | ✓ | ✓ |
| |||
- | if solo | ✓ | ✓ | ✓ | |||
always |
|
| ✓ | Decrement, pre- or post- '--' ((--X) or (X--)) | |||
++ | always |
|
| ✓ | Decrement, pre- or post- '++' ((++X) or (X++)) | ||
* | *= | ✓ | ✓ |
| Multiply, Return Low '*', '*=', multiply and return lower 32 bits (signed) | ||
** | **= | ✓ |
|
| Multiply, Return High '**', '**=', multiply and return upper 32 bits (signed) | ||
/ | /= | ✓ | ✓ |
| Divide '/', '/=' (signed) | ||
// | //= | ✓ |
|
| Modulus '//', '//=' (signed) | ||
#> | #>= | ✓ | ✓ |
| Limit Minimum '#>', '#>=' (signed) | ||
<# | <#= | ✓ | ✓ | Limit Maximum '<#', '<#=' (signed) | |||
^^ | if solo | ✓ | ✓ | ✓ | |||
| | | if solo | ✓ | ✓ | Absolute Value '| |' | |||
~ | always |
|
| ✓ | Sign-Extend 7 or Post-Clear '~', sign-extend from bit 7 (~X) or post-clear to 0 (X~); all bits low | ||
~~ | always |
|
| ✓ | Sign-Extend 15 or Post-Set '~~', sign-extend from bit 15 (~~X) or post-set to -1 (X~~); all bits high | ||
~> | ~>= | ✓ |
|
| |||
? | always |
|
| ✓ | Random '?', random number forward (?X) or reverse (X?) | ||
|< | if solo | ✓ | ✓ | Bitwise Decode '|<', decode value (0 - 31) into single-high-bit long | |||
>| | if solo | ✓ | ✓ | Bitwise Encode '>|', encode long into value (0 - 32) as high-bit priority | |||
<< | <<= | ✓ |
|
| |||
>> | >>= | ✓ |
|
| |||
<- | <-= | ✓ |
|
| |||
-> | ->= | ✓ |
|
| |||
>< | ><= | ✓ |
|
| |||
& | &= | ✓ |
|
| |||
| | |= | ✓ | ✓ | Bitwise OR '|', '|=' | |||
^ | ^= | ✓ |
| ||||
! | if solo | ✓ |
| ✓ | |||
AND | AND= | ✓ | ✓ |
| Boolean AND 'AND', 'AND=' (promotes non-0 to -1) | ||
OR | OR= | ✓ | ✓ |
| Boolean OR 'OR', 'OR=' (promotes non-0 to -1) | ||
NOT | if solo | ✓ | ✓ | ✓ | Boolean NOT 'NOT' (promotes non-0 to -1) | ||
== | === | ✓ | ✓ |
| |||
<> | <>= | ✓ | ✓ |
| |||
< | <= | ✓ | ✓ |
| Boolean Is Less Than '<', '<=' (signed) | ||
> | >= | ✓ | ✓ |
| Boolean Is Greater Than '>', '>=' (signed) | ||
=< | =<= | ✓ | ✓ |
| Boolean Is Equal or Less '=<', '=<=' (signed) | ||
=> | =>= | ✓ | ✓ |
| |||
@ | never | ✓ |
| ✓ | |||
@@ | never |
|
| ✓ |
1 Assignment forms of operators are not allowed in constant expressions.
Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.