Skip to main content

Operator

Currently Supported Operators

PriorityKeywordExample UsageDescription
1()(1 + 1)(expr)
2--12-number_expr (Negation)
2!!true!bool_expr (Logical NOT)
2~~12~integer_expr (Bitwise NOT)
3/1 / 2Division
3*1 * 2Multiplication
3%5 % 2Remainder
4+1 + 1Addition
4-1 - 1Subtraction
5<<100 << 2Bitwise Left Shift
5>>100 >> 2Bitwise Right Shift
6>1 > 2Greater Than
6>=1 >= 2Greater Than or Equal
6<1 < 2Less Than
6<=1 <= 2Less Than or Equal
7==1 == 2Equal To
7!=1 != 2Not Equal To
8&1 & 2Bitwise AND
9^1 ^ 2Bitwise XOR
10|1 | 2Bitwise OR
11&&true && trueLogical AND
12||true || trueLogical OR
13=a = 1Assignment
13%=a %= 1Equivalent to a = a % 1
13*=a *= 1a = a * 1
13/=a /= 1a = a / 1
13+=a += 1a = a + 1
13-=a -= 1a = a - 1
13|=a |= 1a = a | 1
13&=a &= 1a = a & 1
13^=a ^= 1a = a ^ 1
13<<=a <<= 1a = a << 1
13>>=a >>= 1a = a >> 1
tip

Due to the numerous int data types, subsequent documentation will use "integer" to represent integers, "float" to represent floating-point numbers, and "number" to include both types.

Points to Note

  • Operators are grouped by priority. When the priority is the same, they are evaluated from left to right.

  • Binary operators (operators with two operands) currently support binary operations of the number and string types, where string only supports '+' and comparison operator signs

  • Bitwise operations only support the "integer" type.