当前位置:网站首页>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
- poj 3237 Tree(树链拆分)
- 场景化面试:关于分布式锁的十问十答
- EasyExcel的讀寫操作
- The solution to the problem that Oracle hugepages are not used, causing the server to be too laggy
- Advantages of robot framework
- The primary key is set after the table is created, but auto increment is not set
- poj 3237 Tree(樹鏈拆分)
- Poj3414 extensive search
- HDU 4391 Paint The Wall 段树(水
猜你喜欢

PIP install beatifulsoup4 installation failed

Golang(1)|从环境准备到快速上手

2022-07-03-cka- latest feedback from fans

事项研发工作流全面优化|Erda 2.2 版本如“七”而至

Teach yourself to train pytorch model to Caffe (III)

JMeter installation under win7

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

Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node

Why can't Chinese software companies produce products? Abandon the Internet after 00; Open source high-performance API gateway component of station B | weekly email exclusive to VIP members of Menon w

R language learning notes
随机推荐
Cross end solution to improve development efficiency rapidly
MMAP
Environment configuration problem record
Deployment of Jenkins under win7
Four components of logger
SQL common syntax records
Efficiency difference between row first and column first traversal of mat data types in opencv
張麗俊:穿透不確定性要靠四個“不變”
总结出现2xx、3xx、4xx、5xx状态码的原因
CRM creates its own custom report based on fetch
QML reported an error expected token ";", expected a qualified name ID
sql常用语法记录
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
HDU 4391 paint the wall segment tree (water
办公遇到的问题--
matlab绘制hsv色轮图
MMAP学习
MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!