当前位置:网站首页>Binary source code, inverse code, complement code
Binary source code, inverse code, complement code
2022-07-28 22:38:00 【Xiaomei is working hard】
Catalog
Binary has original code 、 Inverse code 、 The existence form of complement
First , We need to know Computers only recognize 0、1 code , That is what we call binary .
therefore , All the data in the computer is based on Binary complement The form , And participate in the operation .
Then why should we use complement form ?, What is the complement ?
Binary has original code 、 Inverse code 、 The existence form of complement
1、 Original code
Because there are positive numbers 、 Existence of negative numbers , So the computer needs to judge the symbol of the stored number when storing , In the computer , The sign bit of a positive number is 0, The sign bit of a negative number is 1.
for example :byte 1 The original code of = 00000001 -1 The original code of = 10000001
1 - 1 = ? Calculate with binary .
In the computer Only adders exist , therefore 1 - 1 === 1 +(-1) Convert to binary
00000001
10000001
10000010 = -2
1 - 1 = -2 This value is obviously wrong , To solve this problem , There's an irony .
2、 Inverse code
The inverse code is changed on the basis of the original code , The inverse of a positive number is the same as the original , The inverse code of a negative number is the original code Except the sign bit Conduct Take the opposite .
for example :1 The inverse of = 1 The original code of = 00000001 -1 The inverse of = 11111110
00000001
11111110
11111111 Inverse code
10000000 -0 Original code
According to the inverse code operation 1 - 1 = -0 , Then there is right in the inverse code 0 Two expressions -0 10000000 and 0 00000000, There is also ambiguity , therefore , There's a complement .
3、 Complement code
Complement is to transform again on the basis of inverse code , The original code of a positive number 、 Inverse code 、 Complement is the same form , The complement of a negative number is based on the inverse +1 .
for example :-1 Complement = 11111110 + 1 = 11111111
00000001
11111111
00000000 0 Complement code Create spillover , The highest position is rounded off
The original code of a positive number 、 Inverse code 、 The complement is the same
So get 1 - 1 = 0 The only correct result of .
therefore , The binary in the computer participates in the operation and storage in the form of complement .
边栏推荐
- gprs网络指的是什么
- PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
- 105. Construct binary tree from preorder and inorder traversal sequence (medium binary tree DFS hash table binary tree)
- JMeter installs third-party plug-ins plugins Manager
- Leetcode integer exercises integer inversion
- Use REM to make the font size adaptive to the screen
- 32. Longest valid bracket (difficult stack string)
- Sword finger offer II 058. schedule (medium design segment tree treemap ordered set)
- 静态成员static详解
- Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
猜你喜欢
Changes in the history of oscilloscope development
imx6q gpio复用
STM32 - external interrupt application (exti) (use cubemx to configure interrupts)
mysql create语句能不能用来建立表结构并追加新的记录
npm ERR code ETIMEDOUT npm ERR syscall connect npm ERR errno ETIMEDOUT npm ERR network reques...
Lvs+keepalived high availability deployment practical application
Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method
Ruiji takeout project - development of business development function Day2
ATT&CK初步了解
Target segmentation learning
随机推荐
redis相关
Why doesn't the icon on the elment plus icon input display
ATT&CK 威胁情报
mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题
MySQL installation and configuration (super detailed, simple and practical)
winServer运维技术栈
Sword finger offer II 055. Binary search tree iterator (medium binary search tree iterator)
776. 字符串移位包含问题
微信小程序使用canvas绘图,圆形头像,网络背景图,文字,虚线,直线
[Ruiji takeout] day05 package management business development
75. Color classification (medium array double pointer sorting)
Leetcode integer exercises integer inversion
imx6q gpio复用
Ruiji takeout project - development of business development function Day2
79. Word search (medium string array matrix backtracking)
775. 倒排单词
JVM——自定义类加载器
XXX port is already in use
使用PCL批量将点云.bin文件转.pcd
Integrating database Ecology: using eventbridge to build CDC applications