Built-In Operations
What is an Infix operation?
It is a math expression with an operator in the middle and two operands, one on each side of the operator. Here are some examples.
1 + 2
1 + 2 + 3
2 + 5 * 4
1 > 2 or 3 > 2
(1 + 2) * 3
1 * -1
Infix operation can be chained as the examples shown above. When chained, the precedence of the operator will decide who gets executed first. If two operator has the same precedence, the operator should be executed from left to right. For example 2 + 5 * 4
will execute 5 * 4
first because the *
operator has a precedence of 200 which is larger than the precedence of the +
operator. The +
operator will then execute 2 + 20
. The second operand 20
comes from the output of the *
operator.
The parentheses can be used to supersede the precedence of the operators as show in #5.
A unary operator such as the negative sign in #6 will always have precedence over any infix operators.