当前位置:网站首页>Original code, inverse code, complement code
Original code, inverse code, complement code
2022-07-29 04:53:00 【BIG_ PEI】
End the conversion of various hexadecimals , Let's talk about another topic : Original code 、 Inverse code 、 Complement code .
We already know that computers , All data is ultimately expressed in binary numbers .
We have also learned how to make a 10 How to convert a base number to a binary number .
however , We still haven't learned how to express a negative number in binary .
such as , Suppose there is a int Number of types , The value is 5, that , We know that it's represented in a computer as :
00000000 00000000 00000000 00000101
5 The conversion to two systems is 101, however int Type of number occupied 4 byte (32 position ), So there's a pile of 0.
Now I want to know ,-5 How to express in a computer ?
In the computer , A negative number is expressed as a complement to its positive value .
What is complement ? This has to come from the original , The irony is that .
Original code : An integer , Binary number converted by absolute value size , It's called the original code .
such as 00000000 00000000 00000000 00000101 yes 5 Of Original code .
Inverse code : Invert binary numbers bit by bit , The resulting new binary number is called the inverse of the original binary number .
Reverse operation means : originally 1, have to 0; originally 0, have to 1.(1 change 0; 0 change 1)
such as : take 00000000 00000000 00000000 00000101 Reverse each bit , have to 11111111 11111111 11111111 11111010.
call :11111111 11111111 11111111 11111010 yes 00000000 00000000 00000000 00000101 The inverse of .
The irony is mutual , So it can also be called :
11111111 11111111 11111111 11111010 and 00000000 00000000 00000000 00000101 It's the opposite of each other .
Complement code : Counter code plus 1 It's called complement .
in other words , To get a complement of numbers , First get the inverse , Then add the inverse to 1, The resulting number is called complement .
such as :00000000 00000000 00000000 00000101 The opposite of :11111111 11111111 11111111 11111010.
that , The complement is :
11111111 11111111 11111111 11111010 + 1 = 11111111 11111111 11111111 11111011
therefore ,-5 It's expressed in a computer as :11111111 11111111 11111111 11111011. Convert to hex :0xFFFFFFFB.
Take another example , Let's look at integers -1 How to express in a computer .
Suppose this is also a int type , that :
1、 First 1 The original code of :00000000 00000000 00000000 00000001
2、 We have to counter : 11111111 11111111 11111111 11111110
3、 Get complement : 11111111 11111111 11111111 11111111
so ,-1 In a computer, binary expression is all 1.16 Into the system for :0xFFFFFF.
边栏推荐
- [c language] PTA 7-63 falling ball
- Academic | [latex] super detailed texlive2022+tex studio download installation configuration
- Implementation of flutter gesture monitoring and Sketchpad
- Delete blank pages in word documents
- Un7.28: common commands of redis client.
- VScode配置makefile编译
- How to monitor micro web services
- Torch.nn.crossentropyloss() details
- Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
- 新产品上市最全推广方案
猜你喜欢
excel怎么设置行高和列宽?excel设置行高和列宽的方法
File operation (Advanced C language)
Download addresses of various versions of MySQL and multi version coexistence installation
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
IOS interview preparation - Online
Corresponding order of 18 and 25coco data of openpose and joint points
Flink+Iceberg环境搭建及生产问题处理
SSM integration, addition, deletion, modification and query
(heap sort) heap sort is super detailed, I don't believe you can't (C language code implementation)
随机推荐
盒子水平垂直居中布局(总结)
Review key points and data sorting of information metrology in the second semester of 2022 (teacher zhaorongying of Wuhan University)
The most complete NLP Chinese and English stop words list in the whole station (including punctuation marks, which can be copied directly)
Learn matlab to draw geographical map, line scatter bubble density map
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
Flutter 手势监听和画板实现
Classes and objects (III)
Opencv environment construction
How to avoid damage of oscilloscope current probe
Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法
spinning up安装完使用教程测试是否成功,出现Library“GLU“ not found和‘from pyglet.gl import *错误解决办法
New year's greetings from programmers
Leetcode 763. partition labels divide alphabetic intervals (medium)
Simple user-defined authentication interface rules
ssm整合增删改查
输入的查询SQL语句,是如何执行的?
1 sentence of code, get asp Net core binds multiple sources to the same class
Using jupyter (I), install jupyter under windows, open the browser, and modify the default opening address
Software test interview questions (4)
在线教育的推荐系统