当前位置:网站首页>【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
边栏推荐
- Disk management and file system
- shell常用命令-备忘录
- 项目实训经历1
- Alibaba cloud SMS authentication third-party interface (fast use)
- 3D打印品牌的康复骨科支具有何特别之处?
- Project training experience 1
- PSI|CSI和ROC|AUC和KS -备忘录
- Memo @restcontrolleradvice and exception interception class example
- Install redis under Windows
- Problems related to compilation and training of Darknet yolov3 and Yolo fast using CUDA environment of rtx30 Series graphics card on win10 platform
猜你喜欢

多模态数据库 | 星环科技多模数据库ArgoDB“一库多用“,构建高性能湖仓集一体平台

Soul continues to make efforts to list its social channels in Hong Kong. Why is "soul style social" popular?

keras-ocr实例测试

Inventory of the world's six most technologically competent smart contract audit companies in 2022

Webodm win10 installation tutorial (personal test)

Linux安装Redis操作

Redis' idea under windows is not connected

Packaging of logging logs

Shell -- conditional statements (if statements, case statements)

Redis operation of Linux Installation
随机推荐
Three methods to judge whether it is palindrome structure
Li Hongyi 2020 deep learning and human language processing dlhlp conditional generation by RNN and attention-p22
向日葵全面科普,为你的远程控制设备及时规避漏洞
When a subclass calls the constructor of its parent class
A cross domain problem of golang
Tips - completely delete the files on the USB flash drive
向日葵教大家如何防范拒绝服务攻击漏洞?
Brief introduction of chip, memory and its key indicators I
项目实训经历1
The difference between malloc and new - Practical chapter
About the problem that Druid can't connect to the database
Converting ArcGIS style stylesheet files to GeoServer SLD files
Linux安装与卸载MySql
Numpy array and image conversion
FTX Foundation funded 15million to help covid-19 clinical trials, which will affect global public health
px4源码编译之 建立自己的程序模块
Px4 source code compilation to establish its own program module
win10 添加虚拟网卡,配置op路由
NFS introduction and configuration
Boostrap