Logical Operators
逻辑运算符
&& | 和(AND) | A && B |
|| | 或(OR) | A || B |
~ | 否(Negation) | ~[1,2,0] |
Mathematical Operators
算数运算符
+ | 加(Addition) | B=3+6 |
+ | 字符连接(String Concatenation) | B=‘john’+‘Doe’ |
+ | 列表或哈希连接(String Concatenation) | list3=list1+list2 |
++ | 自增(Increment) | A++ |
- | 减(Subtraction) | C=9-5 |
- | 取反(Negation) | C =-C |
– | 自减(Decrement) | A– |
* | 乘(Multiplication) | C=2*5 |
* | 指针取消引用(Pointer dereference) | |
/ | 除(Division) | D=10.0/3.2 |
^ | 乘方(Exponentiation) | B=2^3 |
MOD | 模(Modulo) | A= 9 MOD 5 |
Bitwise Operators
位运算符
AND | 按位与(Bitwise AND) | 5 AND 6 = 4 |
NOT | 按位取反(Bitwise NOT) | NOT 4 = -5 |
OR | 按位或(Bitwise OR) | 3 OR 5 = 7 |
XOR | 按位异或(Bitwise exclusive OR) | 3 XOR 5 = 6 |
Relational Operators
关系运算符
EQ | 等于(Equal to) | 2 EQ 2.0 |
NE | 不等于(Not Equal to) | ‘sun’ EQ ‘fun’ |
GE | 大于等于(Greater than or equal to) | A GE 100 |
GT | 大于(Greater than) | A GT 5 |
LE | 小于等于(Less than or equal to) | A LE B |
LT | 小于(Less than) | A LT B |
Opertor Precedence
运算符优先级
First (highest) | ( ) (parentheses, to group expressions) |
First (highest) | [ ] (brackets, to concatenate arrays) |
Second | . (structure field dereference) |
Second | [ ] (brackets, to subscript an array) |
Second | ( ) (parentheses, used in a function call) |
Third | * (pointer dereference) |
Third | ^ (exponentiation) |
Third | ++ (increment) |
Third | – (decrement) |
Fourth | * (multiplication) |
Fourth | # and ## (matrix multiplication) |
Fourth | /(division) |
Fourth | MOD (modulus) |
Fifth | + (addition) |
Fifth | - (subtraction and negation) |
Fifth | < (minimum) |
Fifth | > (maximum) |
Fifth | NOT (bitwise negation) |
Fifth | ~ (logical negation) |
Sixth | EQ (equality) |
Sixth | NE (not equal) |
Sixth | LE (less than or equal) |
Sixth | LT (less than) |
Sixth | GE (greater than or equal) |
Sixth | GT (greater than) |
Seventh | AND (bitwise AND) |
Seventh | OR (bitwise OR) |
Seventh | XOR (bitwise exclusive OR) |
Eighth | && (logical AND) |
Eighth | || (logical OR) |
Ninth | ?: (conditional expression) |
Matrix Operators
矩阵运算符
# | 通过将第一个数组的列乘以第二个数组的行来计算数组元素。第二个数组的列数必须与第一个数组的行数相同。所得数组的列数与第一个数组相同,行数与第二个数组相同。 | A#B |
## | 通过将第一个数组的行乘以第二个数组的列来计算数组元素。第二个数组的行数必须与第一个数组的列数相同。所得数组的行数与第一个数组相同,列数与第二个数组相同。 | B##A |
Minimum and Maximum Operators
最大最小运算符
< | 最小运算符 | X=X0<X1<X2 | X为三者中最小值 |
> | 最大运算符 | X=X0>X1>X2 | X为三者中最大值 |
Other Operators
其他运算符
[] | 数组连接(Array concatenation) | C = [0, 1, 3] |
[ : : ] | 冒号运算符(Colon operator) | [0:10] |
() | 顺序控制与参数封装 | ( 3 +( 4 * 2)^ 2 / 2) |
?: | 条件表达式(Conditional expression) | Z = (A GT B) ? A : B |
. | 方法调用(Method invocation) | oWindow.Draw |
-> | 方法调用(Method invocation) | oWindow->Draw |
Assignment and Compound Assignment
分配和复合分配
= | 分配(Assignment) | A = 0 |
op= | 复合分配(Compound Assignment) (op为运算符) | A + = 5 |