ugBASIC gives the following operators:
Operator | Description | Example |
---|---|---|
# | Constant conversion | #42 |
+ | Arithmetic sum | 42 + 2 |
++ | Arithmetic increment | a++ |
+ | String concatenation | “xx” + “yy”“ |
- | Arithmetic subtraction | 42 - 2 |
- | Arithmetic negation | -42 |
– | Arithmetic decrement | a– |
* | Arithmetic multiplcation | 42 * 2 |
** | Arithmetic multiplcation (power of 2) | 42 * 8 |
^ | Arithmetic power | 42 ^ 2 |
/ | Arithmetic division | 42 / 10 |
\ | Arithmetic division (power of 2) | 42 \ 4 |
mod | Arithmetic modulo | 42 MOD 2 |
= | Assign operator (by copy) | a = 42 |
:= | Assign operator (by reference) | a := b |
= | Equal comparison | a = b |
== | Equal comparison | a = b |
<> | Not equal comparison | a <> b |
> | Greater than comparison | a > b |
>= | Greater than or equal to comparison | a >= b |
< | Less than comparison | a < b |
⇐ | Less than or equal to comparison | a ⇐ b |
AND | Logical / bitwise AND | a AND b |
OR | Logical / bitwise OR | a OR b |
XOR | Logical / bitwise XOR | a XOR b |
NOT | Logical / bitwise NOT | NOT a |
Operands for the arithmetic operators can be any numeric expressions,
or variables. The +
operator is overloaded, because it has also
the meaning of “sum” (concatenate) strings. In this case both operands must
be strings.
Comparison operators can be used with any numeric expressions. A relational expression evaluates to true (-1 / 255) when the comparison is satisfied, and 0 when it does not. Comparison operators can be used with strings too, and comparison is lexicographic.
Finally, logical operators can operate on all numeric data types.