当前位置:网站首页>【11】 Binary code: "holding two roller handcuffs, crying out for hot hot hot"?
【11】 Binary code: "holding two roller handcuffs, crying out for hot hot hot"?
2022-07-27 06:53:00 【As bright as noon】
【 The principle of computer organization 】 Learning notes —— General catalogue
【11】 Binary code :“ Hold two Kunjin handcuffs , I cried out in my mouth ”?
- Recommended reading :《 code : Language hidden behind computer hardware and software 》
introduction
One 、 Understand binary “ On the two into one ”
Binary conversion 10 Base number : 0011【 Binary number 】, 0×23+0×22+1×21+1×20=3【0011 Corresponding decimal number 】
10 Turn into the system 2 Base number 【 Short division 】
- such as , We want to 13 This decimal number , Convert to binary by short division , You need to go through the following steps : therefore , The corresponding binary number , Namely 1101.

- such as , We want to 13 This decimal number , Convert to binary by short division , You need to go through the following steps : therefore , The corresponding binary number , Namely 1101.
Original code notation
- Positive numbers :0011【 representative 3, First place 0 For a positive number 】
- negative :1011【 representative -3, First place 1 It's a negative number 】
- problem :1000 and 0000 All represent 0, wasted 1 Number
extraction Complement code 【 The first is 1 when , It's a negative number , To 10 Base time , Put a minus sign on the far left 】
- example : One 4 Binary complement value of bit 1011, Convert to decimal , Namely −1×23+0×22+1×21+1×20
- The method of finding decimal complement 【 Add... In reverse 1】: -5 Corresponding to a signed bit negative number 5(10000101)→ All bits except sign bits are negated (11111010)→ Add 00000001 by (`11111011)0【-5 The complement of is 11111011】
- Of course More important yes , Use a complement to show a negative number , Make our It's easy to add integers , There's no need to do anything special , Just add it as a normal binary , You can get the right results .

Two 、 Representation of a string , From coding to numbers
1、 ASCII code (American Standard Code for Information Interchange, American standard code for information exchange )
2、 Binary serialization saves more memory space than string representation 【 Integers 、 Representation of numeric values such as floating point numbers 】
We can see , maximal 32 An integer , Namely 2147483647. If it's expressed as an integer , It only needs 32 A bit means . But if you use strings to represent , Altogether 10 Characters , Use... For each character 8 A word of , Need to be whole 80 position . Compared with integer representation , Take up a lot more space .
That's why , A lot of times when we store data , It's binary serialization , Rather than simply passing data through CSV perhaps JSON, This text format is stored for serialization . Whether it's an integer or something , Floating point numbers are good , Using binary serialization will save a lot of space than storing text .
3、 introduce Unicode Character set
ASCII The code just means 128 Characters , It's enough at first . But as more and more people in different countries use computers , I want to express words like Chinese ,128 There are obviously not enough characters . therefore , Computer engineers began to show their own magic , Create a corresponding... For your country's language Character set (Charset) and Character encoding (Character Encoding).
Character set 【 A collection 】, It can represent a set of characters . such as “ chinese ” It's a character set , But it's not accurate to describe a character set like this . Want to be more precise , We can say ,“ The first edition 《 Xinhua dictionary 》 All the Chinese characters in it ”, This is a character set . such , We can know for sure , A character is not in this set . such as , What we say every day Unicode, It's actually a character set , Contains 150 Language 14 Ten thousand different characters .
Character encoding 【 A set of conversion rules 】, It is For these characters in the character set , How to 11 a dictionary expressed in binary . What we said above Unicode, You can use it UTF-8、UTF-16, Even UTF-32 To code , Store as binary . therefore , With Unicode, In fact, we can use more than UTF-8 A form of coding , We can also invent our own GT-32 code , For example, it's called Geek Time 32 Okay . As long as others know the coding rules , It can be transmitted normally 、 Show this code .
4、“ Hold two Kunjin handcuffs , I cried out in my mouth ” Why ?【 The code problem 】
The essence of garbled code : The encoding and decoding are inconsistent
summary 【 Key points of personal summary 】
Original code One of the most intuitive drawbacks of notation is ,0 It can be expressed in two different codes ,1000 representative 0, 0000 On behalf of 0.
use Complement code To represent negative numbers , Make it easy to add our integers , There's no need to do anything special , Just add it as a normal binary , You can get the right results .
Practical application of complement : Binary to decimal 【 Binary is negative 】; Decimal negative to binary 【 Add... In reverse 1】
Inverse code It is usually used to find the complement from the original code or the transition code from the complement to the original code .
- When the inverse code is positive with the original code , equally (0001 The opposite of 0001); When negative , The inverse code is the original code, except for the sign bit , Other bits are reversed .(1001 The opposite of 1110)
What we say every day Unicode, It's actually a character set , Contains 150 Language 14 Ten thousand different characters .
Character set (Charset): A character aggregate .
Character encoding (Character Encoding): A set of Characters and numbers Of Conversion or correspondence The rules .
Character encoding is for these characters in the character set , How to 11 a dictionary expressed in binary . What we said above Unicode, You can use it UTF-8、UTF-16, Even UTF-32 To code , Store as binary .
The problem of garbled code is actually The encoding and decoding are inconsistent The problem of
【 The principle of computer organization 】 Learning notes —— General catalogue
边栏推荐
- Install redis under Windows
- 如何删除或替换EasyPlayer流媒体播放器的loading样式?
- gin-vue-admin 使用docker容器中的数据库
- FTP service introduction and configuration
- Shell sentence judgment exercise
- Use -wall to clear code hidden dangers
- 使用密钥方式登录阿里云服务器
- Boostrap
- Publish a building segmentation database with a resolution of 0.22m
- FTX Foundation funded 15million to help covid-19 clinical trials, which will affect global public health
猜你喜欢

Build cloud native operating environment

Express接收请求参数

DNS domain name resolution service

Record of pychart running jupyter notebook in virtual environment

改善宝宝过敏就吃伊敏舒,azg与Aibeca爱楽倍佳携手守护中国宝宝成长

LVM and disk quota

ES6的新特性(2)
![Summary of frequently asked questions in the interview [summarized after painstaking work all night]](/img/70/90543c23326305590242716b989643.png)
Summary of frequently asked questions in the interview [summarized after painstaking work all night]

Detection and identification data set and yolov5 model of helmet reflective clothing

Px4 source code compilation to establish its own program module
随机推荐
Inventory of the world's six most technologically competent smart contract audit companies in 2022
A cross domain problem of golang
Project training experience 2
Use of getattr, hasattr, delattr and setattr in reflectors
EasyCVR平台播放设备录像时,拖动时间轴播放无效是什么原因?
Shell programming specification and redirection and pipeline operation
Redis' idea under windows is not connected
Detection and identification data set and yolov5 model of helmet reflective clothing
Redis operation of Linux Installation
goLang的一个跨域问题
账号管理与权限
关于过快S验证码的一些问题
PXE efficient batch network installation
Sunflower popularizes Science in an all-round way to avoid loopholes for your remote control equipment in time
众多世界500强企业集聚第二届数博会,数字产业大幕即将开启!
关于在Gazebo中给无人机添加相机(摄像头)之后,无人机无法起飞
向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解
如何删除或替换EasyPlayer流媒体播放器的loading样式?
Problems related to compilation and training of Darknet yolov3 and Yolo fast using CUDA environment of rtx30 Series graphics card on win10 platform
Talk about why you need to declare the member function of a class as private