Operators
Operators allow creating expressions by modifying or calculating values from others, known as "operands".
Depending on the type of operation to perform, and/or the data type they apply to, operators can be classified as:
- Arithmetic operators. Applied in mathematical operations, and the result of their application is always a number.
- Logical operators. Applied in logical operations, and the result of their application is always a boolean value (true / false).
- String operators. Applied to strings, and the result of their application is always a string value.
- Relational operators. Applied in comparison operations, and the result of their application is always a boolean value (true / false).
Additionally, depending on the number of operands the operator acts on, they can be classified as:
- Unary operators. These operators act on a single operand.
- Binary operators. These operators act on two operands.
The following table summarizes the list of all operators available in the Gear Studio platform, classified by operation type. In each case, additional information can be obtained by clicking on the respective operator.
Arithmetic operators
Arithmetic operators are applied in mathematical operations, and the result of their application is always a number.
| Operator | Explanation | Unary / Binary |
|---|---|---|
| + | Adds the two numbers on each side of the operator. | Binary |
| - | Takes the number to the left of the operator and subtracts the number to the right of the operator. | Binary |
| * | Multiplies the two numbers on both sides of the operator. | Binary |
| / | Takes the number to the left of the operator and divides it by the number to the right of the operator. | Binary |
| MOD | Takes the number to the left of the operator, divides it by the number to the right of the operator, and returns the remainder of the division. | Binary |
| - | Sign change. This unary operator changes the sign of the operand to its right. | Unary |
| NOT | Takes the number given as a parameter, considered as a 32-bit integer, and inverts all bits. Commonly known as "bitwise NOT". | Unary |
| AND | Takes the operands on both sides of the operator, considered as 32-bit integers, and performs a logical AND operation for each bit of both operands. Commonly known as "bitwise AND". | Binary |
| OR | Takes the operands on both sides of the operator, considered as 32-bit integers, and performs a logical OR operation for each bit of both operands. Commonly known as "bitwise OR". | Binary |
| XOR | Takes the operands on both sides of the operator, considered as 32-bit integers, and performs a logical XOR operation for each bit of both operands. Commonly known as "bitwise XOR". | Binary |
Logical operators
Logical operators are applied in logical operations, and the result of their application is always a boolean value (true / false).
| Operator | Explanation | Unary / Binary |
|---|---|---|
| NOT | Computes the complement of the operand to the right of the operator. If the operand is true, the result is false and vice versa. | Unary |
| AND | Computes the logical AND operation between the operands on both sides of the operator. The AND operation results in a true value only when both operands have a true value, and false otherwise. | Binary |
| OR | Computes the logical OR operation between the operands on both sides of the operator. The OR operation results in a true value if at least one of the operands has a true value, and false in any other case. | Binary |
| XOR | Computes the logical XOR operation between the operands on both sides of the operator. The XOR operation results in a true value if only one of the operands has a true value, and false in any other case. | Binary |
String operators
String operators are applied to character strings, and the result of their application is always a string value.
| Operator | Explanation | Unary / Binary |
|---|---|---|
| + | Concatenates (joins) the operands on both sides of the operator, using the left one first, and then concatenating the right one. | Binary |
Relational operators
Relational operators are applied in comparison operations, and the result of their application is always a boolean value (true / false). They can be applied to any data type, but in all cases, both operands must be of the same type. It is important to remember some comparison rules:
- When comparing boolean values, the value true is considered greater than the value false.
- For string values, a string is considered greater than another if it is sorted alphabetically after the other.
| Operator | Explanation | Unary / Binary |
|---|---|---|
> | Compares the operands on both sides of the operator and returns true when the left operand is greater than the right one. | Binary |
>= | Compares the operands on both sides of the operator and returns true when the left operand is greater than or equal to the right one. | Binary |
< | Compares the operands on both sides of the operator and returns true when the left operand is less than the right one. | Binary |
<= | Compares the operands on both sides of the operator and returns true when the left operand is less than or equal to the right one. | Binary |
= | Compares the operands on both sides of the operator and returns true when both are equal. | Binary |
<> | Compares the operands on both sides of the operator and returns true when both are different. | Binary |