当前位置:网站首页>【嵌入式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
边栏推荐
- SuperMap game engine license module division
- 机器学习基础-决策树-12
- A brief introduction to the for loop. Some of the code involves arrays
- What if the win11 folder cannot be opened
- Merge table rows - three levels of for loop traversal data
- 单调栈Monotonic Stack
- .NET的求复杂类型集合的差集、交集、并集
- leetcode 376. Wiggle Subsequence
- [cute new problem solving] climb stairs
- Summary: golang's ide:vscode usage
猜你喜欢

Leetcode: array

Connected Block & food chain - (summary of parallel search set)

FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca

LeetCode84 柱状图中最大的矩形

Problem solving during copilot trial

Review the IO stream again, and have an in-depth understanding of serialization and deserialization

Hc-05 Bluetooth module debugging slave mode and master mode experience
![[pictures and texts] detailed tutorial of one click reinstallation of win11 system](/img/cc/749fe4095fc5afb1fc2c65df43d06c.png)
[pictures and texts] detailed tutorial of one click reinstallation of win11 system
![[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32](/img/27/58fd175753b21dc21bd2d950cf5f15.png)
[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32

大模型哪家强?OpenBMB发布BMList给你答案!
随机推荐
Sliding Window
Ccf201912-2 recycling station site selection
Solution to the binary tree problem of niuke.com
The 'name' attribute value associated with the element type 'item' cannot contain '& lt;' Character solution
LeetCode94. 二叉树的中序遍历
Siemens docking Leuze BPS_ 304i notes
Force buckle 315 calculates the number of elements smaller than the current element on the right
区块反转(暑假每日一题 7)
C# 泛型是什么、泛型缓存、泛型约束
SuperMap game engine license module division
VS code更新后不在原来位置
Detailed explanation of the usage of C # static
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
机器学习实战-逻辑回归-19
Unity loads GLB model
[cute new problem solving] climb stairs
20220728 common methods of object class
What is C generic, generic cache, generic constraint
C structure use
01 pyechars 特性、版本、安装介绍