当前位置:网站首页>【嵌入式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
边栏推荐
- 与元素类型 “item” 相关联的 “name” 属性值不能包含'<” 字符解决办法
- What if the win11 folder cannot be opened
- 合并表格行---三层for循环遍历数据
- FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
- 1331. Array sequence number conversion: simple simulation question
- JSP自定义标签之自定义分页标签02
- Change the document type in endnode and import it in word
- 01 introduction to pyechars features, version and installation
- Remove the plug-in of category in WordPress link
- Full disclosure! Huawei cloud distributed cloud native technology and Practice
猜你喜欢

Xampp Chinese tutorial guide

Cloud native - runtime environment

Change the document type in endnode and import it in word

The largest rectangle in leetcode84 histogram

Siemens docking Leuze BPS_ 304i notes

Unity installs the device simulator

Introduction to border border attribute

04 pyechars 地理图表(示例代码+效果图)

Huawei cloud Gao Hongxia: CBC microservice code Reconstruction & independent release practice

Interface control telerik UI for WPF - how to use radspreadsheet to record or comment
随机推荐
Block reversal (summer vacation daily question 7)
Solution to using json.tojsonstring to display question marks in Chinese in Servlet
Vs code is not in its original position after being updated
Merge sort
Using JSON in C language projects
Detailed explanation of the usage of C # static
C# static的用法详解
Which big model is better? Openbmb releases bmlist to give you the answer!
Leetcode 42. rainwater connection
AVL tree (balanced search tree)
C# 结构使用
05 pyechars 基本图表(示例代码+效果图)
Can molecular modeling solve the data dilemma of AI pharmacy?
[pictures and texts] detailed tutorial of one click reinstallation of win11 system
Machine learning practice - decision tree-22
Cloud native - runtime environment
Solution to the binary tree problem of niuke.com
[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32
Sliding Window
What if win11 cannot recognize Ethernet