当前位置:网站首页>【嵌入式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
边栏推荐
- DART 三维辐射传输模型申请及下载
- STM32F103 several special pins are used as ordinary io. Precautions and data loss of backup register 1,2
- Installation and reinstallation of win11 system graphic version tutorial
- Scala transformation, filtering, grouping, sorting
- Initialization examples of several modes of mma8452q
- CCF201912-2 回收站选址
- Zurich Federal Institute of technology | reference based image super resolution with deformable attention transformer (eccv2022))
- 非标自动化设备企业如何借助ERP系统,做好产品质量管理?
- MySQL is always installed unsuccessfully. Just do it like this
- 机器学习实战-神经网络-21
猜你喜欢

大模型哪家强?OpenBMB发布BMList给你答案!

scala 转换、过滤、分组、排序

VS code更新后不在原来位置

Fundamentals of machine learning Bayesian analysis-14

Unity installs the device simulator

What if win11 cannot recognize Ethernet

SQL most commonly used basic operation syntax

SuperMap iclient3d for webgl to realize floating thermal map

Ruan Bonan of Green Alliance Technology: cloud native security from the open source shooting range

DART 三维辐射传输模型申请及下载
随机推荐
机器学习实战-逻辑回归-19
JSP自定义标签之自定义分页标签02
Science heavyweight: AI design protein has made another breakthrough, and it can design specific functional proteins
机器学习实战-决策树-22
机器学习基础-集成学习-13
Full disclosure! Huawei cloud distributed cloud native technology and Practice
机器学习实战-集成学习-23
快速读入
Problem solving during copilot trial
Brother bird talks about cloud native security best practices
How to open the power saving mode of win11 system computer
归并排序
Installation and reinstallation of win11 system graphic version tutorial
Merge sort
Solution to using json.tojsonstring to display question marks in Chinese in Servlet
Leetcode206 reverse linked list
Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
Summary: golang's ide:vscode usage
05 pyechars basic chart (example code + effect diagram)
Uniapp 应用开机自启插件 Ba-Autoboot