当前位置:网站首页>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.
边栏推荐
- Common rules of makefile (make) (II)
- Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
- Mysql各版本下载地址及多版本共存安装
- 虚拟偶像的歌声原来是这样生成的!
- 带你一文理解JS数组
- Various configurations when pulsar starts the client (client, producer, consumer)
- Mujoco and mujoco_ Install libxcursor.so 1:NO such dictionary
- 让你的正则表达式可读性提高一百倍
- MySQL定时调用预置函数完成数据更新
- Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
猜你喜欢

Google browser opens the web page and out of memory appears

Flutter 手势监听和画板实现

Flink+iceberg environment construction and production problem handling

如何安装office2010安装包?office2010安装包安装到电脑上的方法

Learn matlab to draw geographical map, line scatter bubble density map

GCC Basics

Deep analysis of data storage in memory (Advanced C language)

Reveal安装配置调试

(heap sort) heap sort is super detailed, I don't believe you can't (C language code implementation)

数据湖:分布式开源处理引擎Spark
随机推荐
(heap sort) heap sort is super detailed, I don't believe you can't (C language code implementation)
央企建筑企业数字化转型核心特征是什么?
Google browser opens the web page and out of memory appears
How to avoid damage of oscilloscope current probe
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
ios面试准备 - 网络篇
如何避免示波器电流探头损坏
钉钉对话框文子转换成图片 不能复制粘贴到文档上
Simple user-defined authentication interface rules
stack和queue和优先级队列(大堆和小堆)模拟实现和仿函数讲解
Introduction to auto.js script development
Office提示系统配置无法运行怎么办?
PHP determines whether the user has logged in. If logged in, the home page will be displayed. If not, enter the login page or registration page
Tower of Hanoi classic recursion problem (C language implementation)
Flutter 手势监听和画板实现
How to build a mobile studio network?
Improve the readability of your regular expressions a hundred times
Nail dialog text converted to pictures cannot be copied and pasted on the document
2022杭电多校联赛第四场 题解
How to open IE browser by running win command