当前位置:网站首页>【嵌入式C基础】第5篇:原码/反码/补码
【嵌入式C基础】第5篇:原码/反码/补码
2022-07-28 11:53:00 【黑猫学长呀】
1 概念
原码
正数原码 = 反码 = 补码
反码
负数:符号位不变,数值位取反
补码
负数:反码加1得到补码
2 有符号数在内存中的存储方式
有符号数在内存中转化为二进制补码进行保存,无符号数直接转化为二进制存储。
转化为反码,符号位不变。
有符号数表示方法3种:原码、反码、补码
构成:符号位+数值部分组成
符号位:1 负 0 正
例题1:有符号数在内存中为1001 0110,对应十进制数为多少?
注意:为有符号数,且符号位为1,即负数,则1001 0110为该数补码
所以该数反码为1001 0101,该数原码为1110 1010,即-106
总结:有符号数在内存中都是以补码存储的
无符号数在内存中直接转化为二进制存储
例题2:
解析:int型默认为有符号类型,有符号类型在内存中以补码形式存储,-1的补码是1111 1111 1111 1111,第一个输出为-1,第二个为无符号型,在内存中以原码存储,所以其为216-1=65535
边栏推荐
- Using JSON in C language projects
- Machine learning Basics - decision tree-12
- 快速读入
- Scala transformation, filtering, grouping, sorting
- 连通块&&食物链——(并查集小结)
- Siemens docking Leuze BPS_ 304i notes
- Monotonic stack
- [base] what is the optimization of optimization performance?
- What if the right button of win11 start menu doesn't respond
- Custom paging tag 02 of JSP custom tag
猜你喜欢

AVL tree (balanced search tree)

机器学习基础-支持向量机 SVM-17

BiliBili Yang Zhou: above efficiency, efficient delivery

Flexpro software: measurement data analysis in production, research and development

The openatom openharmony sub forum was successfully held, and ecological and industrial development entered a new journey

Summary: idea problem record
![[June 28 event preview] low code Summit](/img/ba/2f35306ed2fb0ece14d704256d8e60.png)
[June 28 event preview] low code Summit

非标自动化设备企业如何借助ERP系统,做好产品质量管理?
![[Bi design teaching] STM32 and FreeRTOS realize low power consumption](/img/2b/3af85135e08599aaa425698c0e83aa.png)
[Bi design teaching] STM32 and FreeRTOS realize low power consumption

Quick read in
随机推荐
Pits encountered in MSP430 development (to be continued)
Quick read in
Can molecular modeling solve the data dilemma of AI pharmacy?
机器学习实战-神经网络-21
LeetCode 移除元素&移动零
[basic teaching of Bi design] detailed explanation of OLED screen use - single chip microcomputer Internet of things
Remove the plug-in of category in WordPress link
Leetcode 42. rainwater connection
Unity installs the device simulator
Huawei cloud Gao Hongxia: CBC microservice code Reconstruction & independent release practice
Vs code is not in its original position after being updated
Block reversal (summer vacation daily question 7)
STM32F103 several special pins are used as ordinary io. Precautions and data loss of backup register 1,2
Hc-05 Bluetooth module debugging slave mode and master mode experience
Ruan Bonan of Green Alliance Technology: cloud native security from the open source shooting range
Full disclosure! Huawei cloud distributed cloud native technology and Practice
C# 泛型是什么、泛型缓存、泛型约束
Communication example between upper computer and Mitsubishi fn2x
Solution to using json.tojsonstring to display question marks in Chinese in Servlet
[June 28 event preview] low code Summit