Operators - Jamiras/RATools GitHub Wiki
-
left + right
- adds numerical values or concatenates string values -
left - right
- subtracts the second value from the first value -
left * right
- multiplies numerical values -
left / right
- divides the first value by the second value, the remainder is discarded -
left % right
- calculates the remainder when the first value is divided by the second value -
left & right
- captures the bits that are non-zero in both values (bitwise and) -
left ^ right
- captures bits differ between values (bitwise xor) -
~left
- inverts the bits of the value
-
left == right
- the two values are equal -
left != right
- the two values are not equal -
left > right
- the first value is greater than the second value -
left >= right
- the first value is greater than or equal to the second value -
left < right
- the first value is less than the second value -
left <= right
- the first value is less than or equal to the second value
left
and right
must be a memory address, a constant, or a function that evaluates to a memory address or constant
-
left && right
- both conditions must be true -
left || right
- either condition must be true -
!left
- the condition must be false
left
and right
must be comparisons or functions that evaluate to comparisons
Operators are evaluated in this order (within a level, operators are evaluated left to right as they're read from the expression):
- Parentheses
- Logical Not
- Multiplication, Division, and Modulus
- Addition and Subtraction
- Bitwise And
- Bitwise XOR
- Bitwise invert
- Comparisons
- Logical And
- Logical Or
The following statement:
N + M * A < B && C > X || D / G * H > Y + Z
Would be interpreted as:
(((N + (M * A)) < B) && (C > X)) || (((D / G) * H) > (Y + Z))
It is particularly important to understand how this affects the creation of alt groups:
A == N && B == X || B == Y
Because AND has higher precedence than OR, the interpreter sees:
(A == N && B == X) || (B == Y)
Which is two alt groups and no core group. An achievement must have a core group, so an always_true
core group will be generated. You can use parentheses to force a different order. What was intended was:
A == N && (B == X || B == Y)
Here, A == N
becomes the core group and there are two alt groups: B == X
and B == Y
.