当前位置:网站首页>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;
边栏推荐
- Some common processing problems of structural equation model Amos software
- Analysis and test of ModbusRTU communication protocol
- Matlab | app designer · I used Matlab to make a real-time editor of latex formula
- Oracle checkpoint queue - Analysis of the principle of instance crash recovery
- 基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
- Robot framework setting variables
- Postgres establish connection and delete records
- Objects in the list, sorted by a field
- Huawei cloud modelarts text classification - takeout comments
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
猜你喜欢

MMAP

Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"

场景化面试:关于分布式锁的十问十答

MMAP

华为云ModelArts文本分类–外卖评论

Ethereum ETH的奖励机制

An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017

ICMP 介绍

Defect detection - Halcon surface scratch detection

MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
随机推荐
Efficiency difference between row first and column first traversal of mat data types in opencv
初级软件测试必问面试题
datagrid直接编辑保存“设计缺陷”
What should I do to prepare for the interview algorithm position during school recruitment?
使用Aspect制作全局异常处理类
有些事情让感情无处安放
EBS Oracle 11g 克隆步骤(单节点)
EasyExcel的讀寫操作
The solution to the problem that Oracle hugepages are not used, causing the server to be too laggy
Parker驱动器维修COMPAX控制器维修CPX0200H
Summary of El and JSTL precautions
Deeply convinced plan X - network protocol basic DNS
秋招将临 如何准备算法面试、回答算法面试题
Matlab | app designer · I used Matlab to make a real-time editor of latex formula
Get JS of the previous day (timestamp conversion)
2022-07-03-cka- latest feedback from fans
MMAP
Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
Zhang Lijun: penetrating uncertainty depends on four "invariants"
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)