jsmubanlogo
  • 首页
  • 网页模板
  • 特效代码
  • 博文源码
  • 插件下载
  •    

运算符优先级

收藏    

作者第十天    2022-02-18

      

Java 运算符优先级
运算符优先级
postfixexpr++ 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++运算符优先级
PrecedenceOperatorDescriptionAssociativity
1::Scope resolutionLeft-to-right
2++   --Suffix/postfix increment and decrement
()Function call
[]Array subscripting
.Element selection by reference
−>Element selection through pointer
3++   --Prefix increment and decrementRight-to-left
+   −Unary plus and minus
!   ~Logical NOT and bitwise NOT
(type)Type cast
*Indirection (dereference)
&Address-of
sizeofSize-of
new, new[]Dynamic memory allocation
delete, delete[]Dynamic memory deallocation
4.*   ->*Pointer to memberLeft-to-right
5*   /   Multiplication, division, and remainder
6+   −Addition and subtraction
7<<   >>Bitwise left shift and right shift
8<   <=For relational operators < and ≤ respectively
>   >=For relational operators > and ≥ respectively
9==   !=For relational = and ≠ respectively
10&Bitwise AND
11^Bitwise XOR (exclusive or)
12|Bitwise OR (inclusive or)
13&&Logical AND
14||Logical OR
15?:Ternary conditionalRight-to-Left
16=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
17throwThrow operator (for exceptions)
18,CommaLeft-to-right
C语言运算符优先级
PrecedenceOperatorDescriptionAssociativity
1++ --Suffix/postfix increment and decrementLeft-to-right
()Function call
[]Array subscripting
.Structure and union member access
−>Structure and union member access through pointer
(type){list}Compound literal(C99)
2++ --Prefix increment and decrementRight-to-left
+ −Unary plus and minus
! ~Logical NOT and bitwise NOT
(type)Type cast
*Indirection (dereference)
&Address-of
sizeofSize-of
_AlignofAlignment requirement(C11)
3* / Multiplication, division, and remainderLeft-to-right
4+ −Addition and subtraction
5<< >>Bitwise left shift and right shift
6< <=For relational operators < and ≤ respectively
> >=For relational operators > and ≥ respectively
7== !=For relational = and ≠ respectively
8&Bitwise AND
9^Bitwise XOR (exclusive or)
10|Bitwise OR (inclusive or)
11&&Logical AND
12||Logical OR
13?:Ternary conditionalRight-to-Left
14=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
15,CommaLeft-to-right
PHP运算符优先级
结合方向运算符附加信息
非结合clone newclone 和 new
左[array()
非结合++ --递增/递减运算符
非结合~ - (int) (float) (string) (array) (object) (bool) @类型
非结合instanceof类型
右结合!逻辑操作符
左* / 算术运算符
左+ - .算术运算符 和 字符串运算符
左<< >>位运算符
非结合< <= > >= <>比较运算符
非结合== != === !==比较运算符
左&位运算符 和 引用
左^位运算符
左|位运算符
左&&逻辑运算符
左||逻辑运算符
左? :三元运算符
右= += -= *= /= .= = &= |= ^= <<= >>=赋值运算符
左and逻辑运算符
左xor逻辑运算符
左or逻辑运算符
左,多处用到

这个表给出Python的运算符优先级(从低到高).

从最低的优先级(最松散地结合)到最高的优先级(最紧密地结合)。

这意味着在一个表达式中,Python会首先计算表中较下面的运算符,然后在计算列在表上部的运算符。

Python 运算符优先级
运算符描述
lambdaLambda表达式
or布尔“或”
and布尔“与”
not x布尔“非”
in,not in成员测试
is,is not同一性测试
<,<=,>,>=,!=,==比较
|按位或
^按位异或
&按位与
<<,>>移位
+,-加法与减法
*,/,乘法、除法与取余
+x,-x正负号
~x按位翻转
**指数
x.attribute属性参考
x[index]下标
x[index:index]寻址段
f(arguments...)函数调用
(experession,...)绑定或元组显示
[expression,...]列表显示
{key:datum,...}字典显示
'expression,...'字符串转换


免责声明:
      1、 资源售价只是赞助,不代表代码或者素材本身价格。收取费用仅维持本站的日常运营所需。
      2、 本站资源来自用户上传,仅供用户学习使用,不得用于商业或者非法用途,违反国家法律一切后果用户自负。用于商业用途,请购买正版授权合法使用。
      3、 本站资源不保证其完整性和安全性,下载后自行检测安全,在使用过程中出现的任何问题均与本站无关,本站不承担任何技术及版权问题,不对任何资源负法律责任。
      4、 如有损害你的权益,请联系275551777@qq.com及时删除。

关于我们 | 积分获取 | 联系我们 | 用户协议 | 标签搜索 | 网站地图.html | 网站地图.xml | 网站地图.txt

Copyright © 2021-2023 All Right Reserved
陕公网安备 61082202000148号      陕ICP备2025078528号-1
js模板网 -陕西千手码农科技有限责任公司