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 |