Skip to main content

Operators

Highest precedence first. Every binary operator is left-associative: a - b - c is (a - b) - c.

LevelOperatorsMeaningOperand kinds
1( ) f(…)grouping, builtin call
2! - ~ (unary)logical not, negate, bitwise not!: any · -: Integer/Real · ~: Integer
3* /multiply, divideInteger/Real
4+ -add or concatenate, subtractInteger/Real, or Text + Text
5<< >>shift left, arithmetic shift rightInteger
6< <= > >=orderingtwo numbers, or two Texts
7== !=equalityany
8&bitwise ANDInteger
9^bitwise XORInteger
10|bitwise ORInteger
11&&logical AND (both sides always evaluated)any (truthiness)
12||logical OR (both sides always evaluated)any (truthiness)

There's no modulo (%), exponent operator, ternary (?:) or comma operator.

warning

&& and || don't short-circuit. Both operands are always evaluated, left then right. A builtin call on the right runs even when the left side already decided the result, and if that call fails, the action stops. Guard with a nested if instead:

text = ClipboardGetText();
idx = StringGetIndexOf(text, ":");

// WRONG: when idx is -1, StringGetSubstring(text, -1, 5) still runs and stops the action
// if (idx >= 0 && StringGetSubstring(text, idx, 5) == ":here") { ... }

// RIGHT: the second test only runs when the first holds
if (idx >= 0) {
if (StringGetSubstring(text, idx, 5) == ":here") UtilityPrint("found");
}
warning

Bitwise operators bind looser than comparisons (the same as C). flags & 4 == 4 is read as flags & (4 == 4), which is flags & true, which is 0. Always wrap the mask: (flags & 4) == 4 or (flags & 4) != 0.

warning

Comparisons don't chain. 0 < x < 10 is read as (0 < x) < 10, which compares a Bool with an Integer and is always false. Write x > 0 && x < 10.