For the complete documentation index, see llms.txt. This page is also available as Markdown.

Arithmetic

Operator
Meaning
Example

+

Add two values

total = a + b;

-

Subtract the right value from the left; unary - negates one value

difference = a - b;

*

Multiply

scaled = value * 125;

/

Integer division; any fractional remainder is discarded

10 / 3 produces 3

%

Remainder after integer division

10 % 3 produces 1

++

Add one

index++;

--

Subtract one

index--;

Prefix changes the variable before the expression result is used; postfix returns the old value and then changes the variable:

b = ++a; // increment a first, then assign the new value to b
b = a++; // assign the old value to b, then increment a

Comparison

Comparison operators return true (1) or false (0):

Operator
Meaning

==

Equal to

!=

Not equal to

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to


Logical

Logical operators treat zero as false and every nonzero value as true:

Operator
Meaning

!a

Logical NOT: true when a is false

a && b

Logical AND: true when both are true

a || b

Logical OR: true when either is true

a ^^ b

Logical XOR: true when exactly one is true


Bitwise

Bitwise operators work on the individual bits of an integer:

Operator
Meaning

~a

Invert every bit

a & b

Bitwise AND; keep bits set in both values

a | b

Bitwise OR; keep bits set in either value

a ^ b

Bitwise XOR; keep bits set in exactly one value

a << n

Shift bits left by n positions

a >> n

Shift bits right by n positions


Conditional

Zen Studio Live supports the ternary conditional operator. It chooses one of two expression values:

GPC evaluates condition first. A nonzero condition selects value_if_true; zero selects value_if_false.

Important: only the selected branch is evaluated. If the condition is true, GPC evaluates value_if_true and does not evaluate value_if_false. If the condition is false, it evaluates value_if_false and does not evaluate value_if_true.

Choose a value

This is the expression form of a small if / else choice. The same logic written longhand is:

The unused branch does not run

Short-circuit branch evaluation makes guarded expressions safe:

The rule also applies to function calls and other side effects:

When use_a is true, only make_a() runs. When it is false, only make_b() runs. Parenthesize nested conditional expressions and keep side effects obvious so the code remains easy to review.


Assignment

Assignment stores the right-hand result in the writable variable or array element on the left. = means "gets the value," not "is equal to." Use == for comparison.

Compound assignment reads the current left-hand value, applies an operation, and writes the result back:

Operator
Equivalent form
Meaning

a = b

Assign b to a

a += b

a = a + b

Add and assign

a -= b

a = a - b

Subtract and assign

a *= b

a = a * b

Multiply and assign

a /= b

a = a / b

Divide and assign

a %= b

a = a % b

Remainder and assign

a &= b

a = a & b

Bitwise AND and assign

a |= b

a = a | b

Bitwise OR and assign

a ^= b

a = a ^ b

Bitwise XOR and assign

a <<= b

a = a << b

Shift left and assign

a >>= b

a = a >> b

Shift right and assign

a &&= b

a = a && b

Logical AND and assign

a ||= b

a = a || b

Logical OR and assign

a ^^= b

a = a ^^ b

Logical XOR and assign

Assignment associates from right to left, so a = b = 5; assigns 5 to b and then assigns that result to a. Prefer one assignment per line when the chained form would hide intent.

Parenthesize mixed bitwise/comparison expressions:

Without parentheses, equality binds more tightly than bitwise AND.

See the exact precedence table in the language reference.

Last updated