当前位置:网站首页>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.
边栏推荐
- Office提示系统配置无法运行怎么办?
- SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案
- Connection database time zone setting
- 荣耀2023内推,内推码ambubk
- Configure st-gcn environment record [Google lab]
- 搭建手机APP需要用到什么服务器
- Reply from the Secretary of jindawei: the company is optimistic about the market prospect of NMN products and has launched a series of products
- How is the entered query SQL statement executed?
- Climbing the pit of traffic flow prediction (III): using pytorch to realize LSTM to predict traffic flow
- [untitled]
猜你喜欢

SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案

Reveal installation configuration debugging

un7.28:redis客户端常用命令。

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

C language implementation of three chess

After the spinning up installation is completed, use the tutorial to test whether it is successful. There are library "Glu" not found and 'from pyglet.gl import * error solutions

Implementation of img responsive pictures (including the usage of srcset attribute and sizes attribute, and detailed explanation of device pixel ratio)

网络之以太网

Solution to the fourth game of 2022 Hangzhou Electric Multi school league

How to set row height and column width in excel? The method of setting row height and column width in Excel
随机推荐
Leetcode (Sword finger offer) - 53 - I. find the number I in the sorted array
[C] PTA 6-8 finding the height of binary tree
Traffic flow prediction pit climbing record (I): traffic flow data set, original data
ios面试准备 - objective-c篇
Detailed comparison of break and continue functions
Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter
Review key points and data sorting of information metrology in the second semester of 2022 (teacher zhaorongying of Wuhan University)
2022杭电多校联赛第四场 题解
Use more flexible and convenient Rogowski coil
[QT learning notes] * insert pictures in the window
IOS interview preparation - IOS
软件测试面试题(四)
Google browser opens the web page and out of memory appears
在线教育的推荐系统
[C language] PTA 7-47 binary leading zero
荣耀2023内推,内推码ambubk
MySQL定时调用预置函数完成数据更新
Live in small private enterprises
Corresponding order of 18 and 25coco data of openpose and joint points
ssm整合增删改查