Skip to content

Operators#

Assignment Operator Description
x = y Basic assignment operator: assigns the value of y to x
x += y Same as x = x + y
x -= y Same as x = x - y
x *= y Same as x = x * y
x /= y Same as x = x / y
x %= y Same as x = x % y
x ^= y Same as x = x ^ y
Operator (Decreasing Precedence) Description
[x , y , z] Vector construction. Ex: v = [0,1,2]
[n] Vector component access by index starting at 0. Ex: x = v[0]
^ Exponentiation (same as pow function). Ex: z = x^y
! Logical NOT
~ Inversion. Ex: y = ~x gives the same result as y = 1 - x
* / % Multiply, divide, modulus
+ - Add, subtract
< > <= >= Comparison (only uses [0] component of vectors)
== != Equality, inequality
&& Logical AND
\ \| Logical OR
? : Conditional. Ex: z = a > 0.5 ? x : y