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

ximagine
ximagine
ximagine
2022年1月23日19:45:2233
0
 1 3464字阅读11分32秒沉浸阅读
宝藏摘要

运算符的优先级决定了表达式中运算执行的先后顺序,优先级高的运算符会作为优先级低的运算符的操作符,优先级从上到下依次递减,最上面具有最高的优先级,逗号操作符具有最低的优先级,优先级高的运算符先结合,优先级低的运算符后结合,同一行中的运算符的优先级相同,荒岛本次带来Java、C++、PHP、Python、C 语言运算符优先级的教程。

荒岛广告位 火热招商中 详情请咨询 荒岛客服号 Q10907252
Java 运算符优先级+ C++ 运算符优先级+ C 语言运算符优先级+ PHP 运算符优先级 Python 运算符优先级
宝藏归属:教程  说明书 发表观点:前往评论 浏览次数:33 次 更新时间:2022年5月21日 09:22:52

运算符的优先级决定了表达式中运算执行的先后顺序,优先级高的运算符会作为优先级低的运算符的操作符。在一个表达式中可能包含多个有不同运算符连接起来的、具有不同数据类型的数据对象,由于表达式有多种运算,不同的结合顺序可能得出不同结果甚至出现错误运算错误,因为当表达式中含多种运算时必须按一定顺序进行结合,才能保证运算的合理性和结果的正确性唯一性。宝藏来自荒岛 - 一座藏有宝藏的小岛-https://x-imagine.com/java-c-php-python-operator-precedence.html

优先级从上到下依次递减,最上面具有最高的优先级,逗号操作符具有最低的优先级。表达式的结合次序取决于表达式中各种运算符的优先级。优先级高的运算符先结合,优先级低的运算符后结合,同一行中的运算符的优先级相同。荒岛本次带来 Java、C++、PHP、Python、C 语言运算符优先级的教程宝藏来自荒岛 - 一座藏有宝藏的小岛-https://x-imagine.com/java-c-php-python-operator-precedence.html

宝藏来自荒岛 - 一座藏有宝藏的小岛-https://x-imagine.com/java-c-php-python-operator-precedence.html

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

宝藏来自荒岛 - 一座藏有宝藏的小岛-https://x-imagine.com/java-c-php-python-operator-precedence.html

Java

运算符 优先级
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++

Precedence Operator Description Associativity
1 :: Scope resolution Left-to-right
2 ++   -- Suffix/postfix increment and decrement
() Function call
[] Array subscripting
. Element selection by reference
−> Element selection through pointer
3 ++   -- 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
newnew[] Dynamic memory allocation
deletedelete[] Dynamic memory deallocation
4 .*   ->* Pointer to member Left-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 conditional Right-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
17 throw Throw operator (for exceptions)
18 , Comma Left-to-right

C 语言

Precedence Operator Description Associativity
1 ++ -- 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)
2 ++ -- 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)
3 * / % Multiplication, division, and remainder Left-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 conditional Right-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 , Comma Left-to-right

PHP

结合方向 运算符 附加信息
非结合 clone new clone 和 new
[ array()
非结合 ++ -- 递增/递减运算符
非结合 ~ - (int) (float) (string) (array) (object) (bool) @ 类型
非结合 instanceof 类型
右结合 ! 逻辑操作符
* / % 算术运算符
+ - . 算术运算符 和 字符串运算符
<< >> 位运算符
非结合 < <= > >= <> 比较运算符
非结合 == != === !== 比较运算符
& 位运算符 和 引用
^ 位运算符
| 位运算符
&& 逻辑运算符
|| 逻辑运算符
? : 三元运算符
= += -= *= /= .= %= &= |= ^= <<= >>= 赋值运算符
and 逻辑运算符
xor 逻辑运算符
or 逻辑运算符
, 多处用到

Python

运算符 描述
lambda Lambda 表达式
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,...' 字符串转换

荒岛宝藏

宝藏来自荒岛 - 一座藏有宝藏的小岛-https://x-imagine.com/java-c-php-python-operator-precedence.html
历史上的今天
1月
23
2022  荒岛宝藏 即将发布 敬请期待...
请按 Ctrl+D 收藏荒岛分享给好友 如您发现本文件已经失效无法下载请联系站长修正
  • 荒岛公众号
  • 扫一扫关注
  • weinxin
  • 荒岛小程序
  • 扫一扫关注
  • weinxin
荒岛广告位 火热招商中 详情请咨询 荒岛客服号 Q10907252
宝藏归属:教程 说明书  荒岛一座藏有宝藏的小岛更新时间:2022-5-21
荒岛广告位 火热招商中 详情请咨询 荒岛客服号 Q10907252

发表评论