当前位置:网站首页>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.
边栏推荐
- Conv2d of torch
- Torch.nn.crossentropyloss() details
- Makefile(make)常见规则(二)
- How to open IE browser by running win command
- Reveal安装配置调试
- Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
- Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
- Connection database time zone setting
- Various configurations when pulsar starts the client (client, producer, consumer)
- 使用近场探头和电流探头进行EMI干扰排查
猜你喜欢

office2010每次打开都要配置进度怎么解决?

IOS interview preparation - IOS

spinning up安装完使用教程测试是否成功,出现Library“GLU“ not found和‘from pyglet.gl import *错误解决办法

1 句代码,搞定 ASP.NET Core 绑定多个源到同一个类

央企建筑企业数字化转型核心特征是什么?

Flink+Iceberg环境搭建及生产问题处理

Build auto.js script development environment

The most comprehensive promotion plan for the launch of new products

使用更灵活、更方便的罗氏线圈

Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
随机推荐
Deep analysis of data storage in memory (Advanced C language)
[untitled]
Box horizontal vertical center layout (summary)
[c language] PTA 7-55 query fruit price
使用更灵活、更方便的罗氏线圈
命令行交互工具(最新版) inquirer 实用教程
学术 | [LaTex]超详细Texlive2022+Tex Studio下载安装配置
1 句代码,搞定 ASP.NET Core 绑定多个源到同一个类
正确的用户拖拽方式
Detailed comparison of break and continue functions
Various configurations when pulsar starts the client (client, producer, consumer)
VScode配置makefile编译
Google browser opens the web page and out of memory appears
如何避免示波器电流探头损坏
Go面向并发的内存模型
C语言实现三子棋
Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法
Leetcode (Sword finger offer) - 53 - I. find the number I in the sorted array
SSM integration, addition, deletion, modification and query
GCC基础知识