当前位置:网站首页>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.
边栏推荐
- Implementation of flutter gesture monitoring and Sketchpad
- 荣耀2023内推,内推码ambubk
- Auto.js脚本开发入门
- 虚拟偶像的歌声原来是这样生成的!
- Build auto.js script development environment
- Ethernet of network
- Office提示系统配置无法运行怎么办?
- Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)
- EMI interference troubleshooting with near-field probe and current probe
- ios面试准备 - objective-c篇
猜你喜欢

Command line interactive tools (latest version) inquirer practical tutorial

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

Using jupyter (I), install jupyter under windows, open the browser, and modify the default opening address

Tower of Hanoi classic recursion problem (C language implementation)

Install the gym corresponding to mujoco in the spinning up tutorial, and the error mjpro150 is reported

How to monitor micro web services

mujoco和mujoco_py安装以及解决libXcursor.so.1:NO such dictionary

【无标题】

Download addresses of various versions of MySQL and multi version coexistence installation

SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案
随机推荐
UE 在场景或UMG中播放视频
Academic | [latex] super detailed texlive2022+tex studio download installation configuration
Torch.nn.crossentropyloss() details
盒子水平垂直居中布局(总结)
ssm整合增删改查
Makefile+Make基础知识
EF core: one to one, many to many configuration
数据湖:分布式开源处理引擎Spark
Opencv environment construction
The difference between the two ways of thread implementation - simple summary
Go面向并发的内存模型
MySQL定时调用预置函数完成数据更新
在线教育的推荐系统
Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)
Recyclerview switches the focus up and down through the dpad key. When switching to the control outside the interface, the focus will jump left and right
Classes and objects (I)
Box horizontal vertical center layout (summary)
Leetcode 763. partition labels divide alphabetic intervals (medium)
Google browser opens the web page and out of memory appears
Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions