日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

Java/C语言/C++/Python/PHP运算符优先级

發(fā)布時(shí)間:2025/3/21 php 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java/C语言/C++/Python/PHP运算符优先级 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Java 運(yùn)算符優(yōu)先級(jí) 運(yùn)算符 優(yōu)先級(jí)
postfix expr++?expr--
unary ++expr?--expr?+expr?-expr?~ !
multiplicative * / %
additive + -
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
ternary ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=
C++運(yùn)算符優(yōu)先級(jí) Precedence Operator Description Associativity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
:: Scope resolution Left-to-right
++???-- Suffix/postfix increment and decrement
() Function call
[] Array subscripting
. Element selection by reference
?> Element selection through pointer
++???-- Prefix increment and decrement Right-to-left
+???? Unary plus and minus
!???~ Logical NOT and bitwise NOT
(type) Type cast
* Indirection (dereference)
& Address-of
sizeof Size-of
new,?new[] Dynamic memory allocation
delete,?delete[] Dynamic memory deallocation
.*???->* Pointer to member Left-to-right
*???/???% Multiplication, division, and remainder
+???? Addition and subtraction
<<???>> Bitwise left shift and right shift
<???<= For relational operators < and ≤ respectively
>???>= For relational operators > and ≥ respectively
==???!= For relational = and ≠ respectively
& Bitwise AND
^ Bitwise XOR (exclusive or)
| Bitwise OR (inclusive or)
&& Logical AND
|| Logical OR
?: Ternary conditional Right-to-Left
= Direct assignment (provided by default for C++ classes)
+=????= Assignment by sum and difference
*=???/=???%= Assignment by product, quotient, and remainder
<<=???>>= Assignment by bitwise left shift and right shift
&=???^=???|= Assignment by bitwise AND, XOR, and OR
throw Throw operator (for exceptions)
, Comma Left-to-right
C語言運(yùn)算符優(yōu)先級(jí) Precedence Operator Description Associativity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
++?-- Suffix/postfix increment and decrement Left-to-right
() Function call
[] Array subscripting
. Structure and union member access
?> Structure and union member access through pointer
(type){list} Compound literal(C99)
++?-- Prefix increment and decrement Right-to-left
+?? Unary plus and minus
!?~ Logical NOT and bitwise NOT
(type) Type cast
* Indirection (dereference)
& Address-of
sizeof Size-of
_Alignof Alignment requirement(C11)
*?/?% Multiplication, division, and remainder Left-to-right
+?? Addition and subtraction
<<?>> Bitwise left shift and right shift
<?<= For relational operators < and ≤ respectively
>?>= For relational operators > and ≥ respectively
==?!= For relational = and ≠ respectively
& Bitwise AND
^ Bitwise XOR (exclusive or)
| Bitwise OR (inclusive or)
&& Logical AND
|| Logical OR
?: Ternary conditional Right-to-Left
= Simple assignment
+=??= Assignment by sum and difference
*=?/=?%= Assignment by product, quotient, and remainder
<<=?>>= Assignment by bitwise left shift and right shift
&=?^=?|= Assignment by bitwise AND, XOR, and OR
, Comma Left-to-right
PHP運(yùn)算符優(yōu)先級(jí) 結(jié)合方向 運(yùn)算符 附加信息
非結(jié)合 clone new clone 和 new
[ array()
非結(jié)合 ++ -- 遞增/遞減運(yùn)算符
非結(jié)合 ~ - (int) (float) (string) (array) (object) (bool) @ 類型
非結(jié)合 instanceof 類型
右結(jié)合 ! 邏輯操作符
* / % 算術(shù)運(yùn)算符
+ - . 算術(shù)運(yùn)算符 和 字符串運(yùn)算符
<< >> 位運(yùn)算符
非結(jié)合 < <= > >= <> 比較運(yùn)算符
非結(jié)合 == != === !== 比較運(yùn)算符
& 位運(yùn)算符 和 引用
^ 位運(yùn)算符
| 位運(yùn)算符
&& 邏輯運(yùn)算符
|| 邏輯運(yùn)算符
? : 三元運(yùn)算符
= += -= *= /= .= %= &= |= ^= <<= >>= 賦值運(yùn)算符
and 邏輯運(yùn)算符
xor 邏輯運(yùn)算符
or 邏輯運(yùn)算符
, 多處用到

這個(gè)表給出Python的運(yùn)算符優(yōu)先級(jí)(從低到高).

從最低的優(yōu)先級(jí)(最松散地結(jié)合)到最高的優(yōu)先級(jí)(最緊密地結(jié)合)。

這意味著在一個(gè)表達(dá)式中,Python會(huì)首先計(jì)算表中較下面的運(yùn)算符,然后在計(jì)算列在表上部的運(yùn)算符。

Python 運(yùn)算符優(yōu)先級(jí) 運(yùn)算符 描述
lambda Lambda表達(dá)式
or 布爾“或”
and 布爾“與”
not x 布爾“非”
in,not in 成員測(cè)試
is,is not 同一性測(cè)試
<,<=,>,>=,!=,== 比較
| 按位或
^ 按位異或
& 按位與
<<,>> 移位
+,- 加法與減法
*,/,% 乘法、除法與取余
+x,-x 正負(fù)號(hào)
~x 按位翻轉(zhuǎn)
** 指數(shù)
x.attribute 屬性參考
x[index] 下標(biāo)
x[index:index] 尋址段
f(arguments...) 函數(shù)調(diào)用
(experession,...) 綁定或元組顯示
[expression,...] 列表顯示
{key:datum,...} 字典顯示
'expression,...' 字符串轉(zhuǎn)換

from:?http://tool.oschina.net/

總結(jié)

以上是生活随笔為你收集整理的Java/C语言/C++/Python/PHP运算符优先级的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。