当前位置:网站首页>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;
边栏推荐
- Poj3414 extensive search
- Reading and writing operations of easyexcel
- Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
- Kingbasees v8r3 data security case - audit record clearing case
- Robot operation mechanism
- Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
- NET中小型企业项目开发框架系列(一个)
- 2022-07-03-CKA-粉丝反馈最新情况
- "Grain mall" -- Summary and induction
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
猜你喜欢
场景化面试:关于分布式锁的十问十答
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Some common processing problems of structural equation model Amos software
xlrd常见操作
Analysis and test of ModbusRTU communication protocol
Recursive query of multi-level menu data
Realize the function of verifying whether the user has completed login when browsing the page
2022-07-03-CKA-粉丝反馈最新情况
怎么利用Tensorflow2进行猫狗分类识别
MMAP学习
随机推荐
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
MMAP
Parker驱动器维修COMPAX控制器维修CPX0200H
EBS Oracle 11g 克隆步骤(单节点)
Net small and medium-sized enterprise project development framework series (one)
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
2.2.3 output of documents
Selenium gets the verification code image in DOM
Get JS of the previous day (timestamp conversion)
DBeaver同时执行多条insert into报错处理
Robot operation mechanism
华为云ModelArts文本分类–外卖评论
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Experienced inductance manufacturers tell you what makes the inductance noisy. Inductance noise is a common inductance fault. If the used inductance makes noise, you don't have to worry. You just need
Learning notes of statistical learning methods -- Chapter 1 Introduction to statistical learning methods
GCC9.5离线安装
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry