当前位置:网站首页>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;
边栏推荐
- 使用Aspect制作全局异常处理类
- one hundred and twenty-three thousand four hundred and fifty-six
- Gcc9.5 offline installation
- 总结出现2xx、3xx、4xx、5xx状态码的原因
- QML reported an error expected token ";", expected a qualified name ID
- POJ 3237 tree (tree chain splitting)
- Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
- crm创建基于fetch自己的自定义报告
- The primary key is set after the table is created, but auto increment is not set
- Opérations de lecture et d'écriture pour easyexcel
猜你喜欢

华为联机对战如何提升玩家匹配成功几率

1.2 download and installation of the help software rstudio

Parker driver maintenance COMPAX controller maintenance cpx0200h

Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)

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

張麗俊:穿透不確定性要靠四個“不變”

Deeply convinced plan X - network protocol basic DNS

QML reported an error expected token ";", expected a qualified name ID

Oracle checkpoint queue - Analysis of the principle of instance crash recovery

MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
随机推荐
Environment configuration problem record
int GetMonth( ) const throw( ); What does throw () mean?
張麗俊:穿透不確定性要靠四個“不變”
CRM creates its own custom report based on fetch
Uni app Bluetooth communication
Opérations de lecture et d'écriture pour easyexcel
使用Aspect制作全局异常处理类
有些事情让感情无处安放
Poj3414广泛搜索
MMAP
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
Gcc9.5 offline installation
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
MMAP learning
张丽俊:穿透不确定性要靠四个“不变”
Simple interest mode - lazy type
SQL common syntax records
Cold violence -- another perspective of objective function setting
poj 3237 Tree(树链拆分)