当前位置:网站首页>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;
边栏推荐
- int GetMonth( ) const throw( );后面的throw( )什么意思?
- Defect detection - Halcon surface scratch detection
- regular expression
- MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
- sql常用语法记录
- Li Kou ----- the maximum profit of operating Ferris wheel
- EasyExcel的读写操作
- Reading and writing operations of easyexcel
- What should I do to prepare for the interview algorithm position during school recruitment?
- Oracle checkpoint queue - Analysis of the principle of instance crash recovery
猜你喜欢

EasyExcel的讀寫操作

What should I do to prepare for the interview algorithm position during school recruitment?

EBS Oracle 11g 克隆步骤(单节点)

Reading and writing operations of easyexcel

DBeaver同时执行多条insert into报错处理

Uni app Bluetooth communication

Emotional analysis of wechat chat records on Valentine's day based on Text Mining

秋招将临 如何准备算法面试、回答算法面试题

深信服X计划-网络协议基础 DNS

Incentive mechanism of Ethereum eth
随机推荐
Cross end solution to improve development efficiency rapidly
大约SQL现场“这包括”与“包括在”字符串的写法
張麗俊:穿透不確定性要靠四個“不變”
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
Cold violence -- another perspective of objective function setting
力扣------经营摩天轮的最大利润
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
matlab绘制hsv色轮图
Image editor for their AutoLayout environment
Zhang Lijun: la pénétration de l’incertitude dépend de quatre « invariants»
int GetMonth( ) const throw( ); What does throw () mean?
张丽俊:穿透不确定性要靠四个“不变”
Poj3414 extensive search
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
HDU 4391 paint the wall segment tree (water
SQL knowledge leak detection
About the writing method of SQL field "this includes" and "included in" strings
Kingbasees v8r3 data security case - audit record clearing case