当前位置:网站首页>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;
边栏推荐
- 让开发效率飞速提升的跨端方案
- Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
- 华为联机对战如何提升玩家匹配成功几率
- 面试官:并发编程实战会吗?(线程控制操作详解)
- Reading and writing operations of easyexcel
- MMAP
- 他们主动布局(autolayout)环境的图像编辑器
- About the writing method of SQL field "this includes" and "included in" strings
- 2022-07-03-CKA-粉丝反馈最新情况
- Clickhouse copy paste multi line SQL statement error
猜你喜欢

Cross end solution to improve development efficiency rapidly

Oracle检查点队列–实例崩溃恢复原理剖析

力扣------经营摩天轮的最大利润

从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析

Alibaba cloud award winning experience: build a highly available system with polardb-x

2.2 basic grammar of R language

SQL knowledge leak detection

Reading and writing operations of easyexcel

使用Aspect制作全局异常处理类

Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
随机推荐
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
Cold violence -- another perspective of objective function setting
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
GCC9.5离线安装
Pointer parameter passing vs reference parameter passing vs value parameter passing
Environment configuration problem record
Chap2 steps into the palace of R language
Gcc9.5 offline installation
Hysbz 2243 staining (tree chain splitting)
如何组织一场实战攻防演练
Realize the function of verifying whether the user has completed login when browsing the page
Oracle检查点队列–实例崩溃恢复原理剖析
Li Kou ----- the maximum profit of operating Ferris wheel
Scenario interview: ten questions and ten answers about distributed locks
oracle 控制文件的多路复用
面试官:并发编程实战会吗?(线程控制操作详解)
Simple interest mode - lazy type
Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
Cross end solutions to improve development efficiency
有些事情让感情无处安放