运算符
运算符 allow creating ex按下ions 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:
- 算术运算符. Applied in mathematical operations, and the result of their application is always a number.
- 逻辑运算符. Applied in logical operations, and the result of their application is always a boolean value (true / false).
- 字符串运算符. Applied to strings, and the result of their application is always a string value.
- 关系运算符. 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:
- 一元 operators. These operators act on a single operand.
- 二元 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 点击ing on the respective operator.
算术运算符
算术运算符应用于数学运算,其应用结果始终是一个数字。
| 运算符 | 说明 | 一元 / 二元 |
|---|---|---|
| + | 将运算符两侧的两个数字相加。 | 二元 |
| - | 取运算符左侧的数字减去运算符右侧的数字。 | 二元 |
| * | 将运算符两侧的两个数字相乘。 | 二元 |
| / | 取运算符左侧的数字除以运算符右侧的数字。 | 二元 |
| MOD | 取运算符左侧的数字除以运算符右侧的数字,返回除法运算的余数。 | 二元 |
| - | 改变符号。该一元运算符改变其右侧操作数的符号。 | 一元 |
| NOT | Takes the number given as a parameter, considered as a 32-bit integer, and inverts all bits. Commonly known as "bitwise NOT". | 一元 |
| 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". | 二元 |
| 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". | 二元 |
| 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". | 二元 |
逻辑运算符
逻辑运算符应用于逻辑运算,其应用结果始终是一个布尔值(true / false)。
| 运算符 | 说明 | 一元 / 二元 |
|---|---|---|
| NOT | 计算运算符右侧操作数的补码。如果操作数为 true,则结果为 false,反之亦然。 | 一元 |
| AND | 计算运算符两侧操作数之间的逻辑 AND 运算。AND 运算仅当两个操作数都为 true 时结果才为 true,其他情况均为 false。 | 二元 |
| OR | 计算运算符两侧操作数之间的逻辑 OR 运算。OR 运算如果两个操作数中至少有一个为 true,则结果为 true,其他情况均为 false。 | 二元 |
| XOR | 计算运算符两侧操作数之间的逻辑 XOR 运算。XOR 运算如果两个操作数中只有一个为 true,则结果为 true,其他情况均为 false。 | 二元 |
字符串运算符
字符串运算符应用于字符序列,其应用结果始终是字符串值。
| 运算符 | 说明 | 一元 / 二元 |
|---|---|---|
| + | 将运算符两侧的操作数连接(拼接)起来,先使用左侧,再拼接右侧。 | 二元 |
关系运算符
关系运算符应用于比较运算,其应用结果始终是一个布尔值(true / false)。它们可以应用于任何数据类型,但在所有情况下,两个操作数必须是同一类型。请记住一些比较规则:
- 比较布尔值时,true 值被认为大于 false 值。
- 对于字符串值,如果一个字符串按字母顺序排在另一个之后,则被认为更大。
| 运算符 | 说明 | 一元 / 二元 |
|---|---|---|
> | 比较运算符两侧的操作数,当左侧操作数大于右侧操作数时返回 true。 | 二元 |
>= | 比较运算符两侧的操作数,当左侧操作数大于或等于右侧操作数时返回 true。 | 二元 |
< | 比较运算符两侧的操作数,当左侧操作数小于右侧操作数时返回 true。 | 二元 |
<= | 比较运算符两侧的操作数,当左侧操作数小于或等于右侧操作数时返回 true。 | 二元 |
= | 比较运算符两侧的操作数,当两者相等时返回 true。 | 二元 |
<> | 比较运算符两侧的操作数,当两者不同时返回 true。 | 二元 |