当前位置:网站首页>[C language] General method of expression evaluation
[C language] General method of expression evaluation
2022-07-31 03:19:00 【rookieﻬ°】
How expressions are evaluated:
- The expression is evaluated to see if there is a shaping promotion or arithmetic conversion, and then the calculation is performed
- When the expression is actually calculated, first look at the priority of the adjacent operators to decide who is calculated first
- In the case of the same priority of adjacent operators, the calculation order is determined by the associativity of the operators
Of course, bad input methods will cause the program to have multipleAs a result, we should therefore write the calculation formula without an uprising.For example, the following code has different results in different compilation environments:
#include int main(){int i = 1;int ret = (++i)+(++i)+(++i);printf("ret = %d\n", ret);return 0;}
Different compilation environments can get the following results:
- 10
- 12
- 9
Therefore, we must pay attention to develop a good code input method.
边栏推荐
猜你喜欢
Compile Hudi
IDEA comment report red solution
浅识Flutter 基本组件之CheckBox组件
【C语言】表达式求值的一般方法
Detailed explanation of TCP (3)
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
想从手工测试转岗自动化测试,需要学习哪些技能?
[Dynamic programming] Maximum sum of consecutive subarrays
【编译原理】递归下降语法分析设计原理与实现
[Compilation principle] Design principle and implementation of recursive descent parsing
随机推荐
Modbus on AT32 MCUs
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
VS QT - ui does not display newly added members (controls) || code is silent
Mysql 45讲学习笔记(二十四)MYSQL主从一致
TCP/IP four-layer model
[C language] Preprocessing operation
Detailed explanation of TCP (3)
【CocosCreator 3.5】CocosCreator get network status
Several common errors when using MP
False positives and false negatives in testing are equally worthy of repeated corrections
The distance value between two arrays of LeetCode simple questions
A brief introduction to the CheckboxListTile component of the basic components of Flutter
LeetCode每日一练 —— OR36 链表的回文结构
CloudCompare&PCL 计算两个点云之间的重叠度
Why SocialFi achievement Web3 decentralized social in the future
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
识Flutter 基本组件之showTimePicker 方法
PMP WeChat group daily exercises
Annotation usage meaning
【C语言】进制转换一般方法