当前位置:网站首页>【嵌入式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
边栏推荐
- 05 pyechars basic chart (example code + effect diagram)
- [basic teaching of Bi design] detailed explanation of OLED screen use - single chip microcomputer Internet of things
- leetcode 1518. 换酒问题
- Insufficient permission to pull server code through Jenkins and other precautions
- Installation and reinstallation of win11 system graphic version tutorial
- Leetcode206 reverse linked list
- C# 泛型是什么、泛型缓存、泛型约束
- Quick read in
- AI制药的数据之困,分子建模能解吗?
- 01 introduction to pyechars features, version and installation
猜你喜欢

What if win11 cannot recognize Ethernet

归并排序
![[cute new problem solving] climb stairs](/img/a2/fd2f21c446562ba9f0359988d97efe.png)
[cute new problem solving] climb stairs
![[basic teaching of Bi design] detailed explanation of OLED screen use - single chip microcomputer Internet of things](/img/76/820d4e357206f936b33da92a5e2b5b.png)
[basic teaching of Bi design] detailed explanation of OLED screen use - single chip microcomputer Internet of things

Ten prohibitions for men and women in love

机器学习实战-神经网络-21

Redefinition problem of defining int i variable in C for loop

SQL most commonly used basic operation syntax

Application and download of dart 3D radiative transfer model
![[June 28 event preview] low code Summit](/img/ba/2f35306ed2fb0ece14d704256d8e60.png)
[June 28 event preview] low code Summit
随机推荐
Linear classifier (ccf20200901)
与元素类型 “item” 相关联的 “name” 属性值不能包含'<” 字符解决办法
机器学习基础-决策树-12
LeetCode206 反转链表
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
Merge sort
Design a thread pool
Vs code is not in its original position after being updated
How to add PDF virtual printer in win11
scala 转换、过滤、分组、排序
线性分类器(CCF20200901)
MySQL limit paging optimization
Merge table rows - three levels of for loop traversal data
Using JSON in C language projects
Shenwenbo, researcher of the Hundred Talents Program of Zhejiang University: kernel security in the container scenario
LeetCode 42.接雨水
[graduation design] oscilloscope design and Implementation Based on STM32 - single chip microcomputer Internet of things
Uniapp 应用开机自启插件 Ba-Autoboot
Datanode data block missing problem finding
New progress in the implementation of the industry | the openatom openharmony sub forum of the 2022 open atom global open source summit was successfully held