当前位置:网站首页>Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
2022-07-05 21:46:00 【Excellent dengzonglei】
Code bug correct ,char Convert to int High sign extension , Cause the positive and negative and numerical values to change ,int num = (int)(unsigned int)a, Problems with older compilers
scene :
char The data type is converted to int when , If you use
char a = 0x9A;
int num = (int)a;
It can be calculated that a Of int The value should be 154, But the actual code is -102, A logical error has occurred .
reason :
To explain in detail, we need to talk about the expression of negative numbers in computers , Need to add a complement or something , This aspect is not very good for the time being .
resolvent :
char a = 0x9A;
int num = (int)(unsigned int)a;
边栏推荐
- Codeforces 12D ball tree array simulation 3 sorting elements
- leetcode:1755. Sum of subsequences closest to the target value
- 递归查询多级菜单数据
- 场景化面试:关于分布式锁的十问十答
- 资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
- Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
- 2.2.3 output of documents
- Detailed explanation of memset() function usage
- int GetMonth( ) const throw( );后面的throw( )什么意思?
- 2.2.5 basic sentences of R language drawing
猜你喜欢
Uni app Bluetooth communication
Deployment of Jenkins under win7
Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
DBeaver同时执行多条insert into报错处理
Drawing HSV color wheel with MATLAB
Chapter 05_ Storage engine
Analysis and test of ModbusRTU communication protocol
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
uni-app 蓝牙通信
随机推荐
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Recursive query of multi-level menu data
How to prepare for the algorithm interview and answer the algorithm interview questions
华为联机对战如何提升玩家匹配成功几率
Zhang Lijun: penetrating uncertainty depends on four "invariants"
Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
ESP32
HYSBZ 2243 染色 (树链拆分)
Cold violence -- another perspective of objective function setting
Get JS of the previous day (timestamp conversion)
JMeter installation under win7
Evolution of zhenai microservice underlying framework from open source component encapsulation to self-development
How to organize an actual attack and defense drill
Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
Image editor for their AutoLayout environment
xlrd常见操作
regular expression
oracle 控制文件的多路复用
MMAP learning
Robot framework setting variables