当前位置:网站首页>C language operator priority formula
C language operator priority formula
2022-06-23 06:54:00 【zetor_ major】
Vinegar jar sour filling
The taste falls and the blessing beans jump
common 44 Operators
vinegar - Elementary ,4 individual : ( ) [ ] -> Point to structural members . Structural members
The altar - Monocular ,9 individual : ! ~ ++ -- - Minus sign ( type ) * The pointer & Address fetch sizeof length ( Combination direction : From right to left )
acid - The arithmetic ,5 individual : * / % + - reduce
taste - Displacement ,2 individual : << >>
irrigation - Relationship ,6 individual : < <= > >= == be equal to != It's not equal to
taste - Bit logic ,3 individual : & Bitwise AND ^ Bitwise XOR | Press bit or
fall - Logic ,2 individual : && Logic and || Logic or
jump - Conditions ,1 individual , Three orders : ? : ( Combination direction : From right to left )
blessing - assignment ,11 individual : = += -= *= /= %= >>= <<= &= ^= |= ( Combination direction : From right to left )
bean - comma ,1 individual : ,
There are only three types of combinations from right to left : assignment 、 Monocular and trinocular , The others are from left to right .
Be careful : I wrote the program today The priority of relational operation symbols and bit logic is reversed . Try to use parentheses , There's no problem .
Such as :if(P1OUT&BIT0==0)P1OUT ^=BIT0; // Judge p1.0 Whether the output is 0, Yes, just flip , On LED.
This line of program is wrong . You can put parentheses around , namely if((P1OUT&BIT0)==0), Or directly :P1OUT|=BIT0;
The operator with the highest priority is not really an operator , They are a special kind of operation .() It's about functions ,[] Array related , and -> And . It's structural members .
The second is the unary operator , All unary operators have the same priority , So in my opinion In real operators, they have the highest priority , And because they are Combined from right to left , therefore *p++ And *(p++) There is no doubt about equivalence .
Next comes the arithmetic operator ,*、/、% Of course, the priority is higher than +、- High .
The shift operator follows .
In the next relational operator ,< <= > >= than == != A higher level , It's not easy to understand .
All logical operators have different priorities ( Monocular operators go out ,! and ~)
Of logical bitwise operators " And " Than " or " high , and " Exclusive or " Between them .
Followed by && Than || high .
Next is the conditional operator , Assignment operator and comma operator .
stay C In language , Only 4 An operator specifies the direction of the operation , They are &&、| |、 Condition operator and assignment operator .
&&、| | We all calculate the value of the expression on the left first , When the value of the left expression can determine the value of the whole expression , The value of the expression on the right is no longer evaluated . Such as a = 0 && b; && The left bit of the operator 0, Then the expression on the right b No longer judge .
In the conditional operator . Such as a?b:c; First judge a Value , According to a The value of is right b or c One of them is evaluated .
The assignment expression specifies that the expression on the right is evaluated first , So make a = b = c = 6; Make it possible .
边栏推荐
- Haas506 2.0 development tutorial -hota (only supports versions above 2.2)
- 994. rotten oranges - non recursive method
- 疫情下的传媒产业,小程序生态驱动数字化转型探索
- QT method of compiling projects using multithreading
- core. What is JS ---kalrry
- Open source to the world (Part 2): the power of open source from the evolution of database technology BDTC 2021
- Haas506 2.0 development tutorial - Advanced Component Library -modem Sim (only supports versions above 2.2)
- 使用ts-node直接运行TypeScript代码
- Haas506 2.0 development tutorial -sntp (only versions above 2.2 are supported)
- idea自动生成serialVersionUID
猜你喜欢

20220621 Three Conjugates of Dual Quaternions

常见设置模式(抽象工厂&责任链模式&观察者模式)

Sword finger offer 42 Maximum sum of successive subarrays

Chrome删除重复书签

How to view native IP

How to realize video call and live interaction in a small program when live broadcasting is so popular?

杂七杂八的东东

XXL-SSO 实现SSO单点登录

光谱共焦的测量原理及厚度测量模式

解决挖矿病毒 sshd2(redis未设密码、清除crontab定时任务)
随机推荐
Topic35——34. Find the first and last positions of elements in a sorted array
haas506 2.0开发教程-高级组件库-modem.sim(仅支持2.2以上版本)
嵌入式实时系统线程的副作用
SAP execution transaction code mrrl error -no message was found for partner 100065-
asp.net文件下载demo与相关问题的处理
Miscellaneous things
Mysql5.6 (5.7-8) is based on shardingsphere5.1.1 sharding proxy mode. Read / write separation
cetos7 记录
Business logic design of physical warehouse and virtual warehouse in middle inventory
xml schem 记录
杂七杂八的东东
Machine learning artifact scikit learn minimalist tutorial
English grammar_ Adjective comparative - Level 3 change
idea自动生成serialVersionUID
2022年养老理财产品有哪些?风险小的
Wechat applet - Global Monitoring of certain attribute changes of GlobalData, such as monitoring of network state switching
中台库存中的实仓与虚仓的业务逻辑设计
Verilog语法讲解
关于五险一金你需要知道的事情
Mongodb record