当前位置:网站首页>Hexadecimal conversion summary
Hexadecimal conversion summary
2022-07-05 12:21:00 【A finger leaf next to the giant】
Preface :
In learning the principles of computer composition chapter 2 - Operation method and arithmetic unit , Encountered a binary conversion problem , As a computer student , About binary conversion, we still need to understand clearly , I want to sum it up for a long time , Here are some calculation methods .
General content of the article : Decimal system , Binary system , Interval adjustment , Decimal conversion
Binary 、 octal 、 Hexadecimal to decimal
Integral part :

The fractional part :

Convert decimal to binary 、 octal 、 Hexadecimal :
Integral part :
Decimal to N Base number , With its number pair N Continuous surplus , Until the quotient is zero , Then arrange the remainder in reverse order , The number obtained is N Result after hexadecimal :
As shown in the figure :
Put the decimal number 36926 The process of converting to octal :
I can see from the picture that , Decimal number 36926 The result of conversion to octal is 110076.
The fractional part :
Convert decimal to N Hexadecimal decimals are “ ride N integer , Sequential arrangement ” Law . The specific way is :
Arrange the integer parts in order , First take the integer as N The high digit of a decimal , Take the integer taken out as the low-order number , So you get N Decimal number .
As shown in the figure :
Put the decimal number 0.930908203125 The process of converting to octal decimal :
Decimal number 0.930908203125 The result of converting to octal decimal is 0.7345.
Binary and octal 、 Hexadecimal conversion :
octal :
Octal as a written form of binary , The base number is 8, Yes 0~7 common 8 A different number symbol , Count " Every eight enters one. ", because r=8=2 The third power of , So as long as the three digits in binary are grouped into a group, it is an octal digit , The conversion between the two is very convenient .
Hexadecimal :
Hexadecimal is also a common writing form of binary , The base number is 16,“ Every 16 to one ”. Each number is desirable 0~9,A,B,C,D,E,F Any one of , among A,B,C,D,E,F respectively 10 ~ 15 . because r=16=2 Of 4 Power , therefore 4 It is a binary number corresponding to a hexadecimal number .
Actually , Any conversion between hexadecimals can use the method mentioned above , But sometimes it's troublesome , Therefore, different methods are generally adopted for different hexadecimals . There is a very simple way to convert binary to octal and hexadecimal , vice versa .
- Conversion between binary and octal integers
When converting binary integers to octal integers , Convert every three binary digits into one octal digit , The order of operations is from low to high , If the high position is less than three digits, fill them with zeros . The following figure shows how to convert binary integers 1110111100 Convert to octal :

As you can see from the diagram , Binary integer 1110111100 The result of conversion to octal is 1674.
When converting octal integers to binary integers , The idea is the opposite , Each octal digit is converted to three binary digits , The order of operations is also from low to high . The following figure shows how to convert octal integers 2743 Convert to binary :

As you can see from the diagram , Octal integer 2743 The result of converting to binary is 10111100011.
- Conversion between binary and hexadecimal integers
When converting binary integers to hexadecimal integers , Convert every four binary digits to one hexadecimal digit , The order of operations is from low to high , If the high position is less than four digits, fill them with zeros . The following figure shows how to convert binary integers 10 1101 0101 1100 Convert to hex :

As you can see from the diagram , Binary integer 10 1101 0101 1100 The result of conversion to hexadecimal is 2D5C.
When converting a hexadecimal integer to a binary integer , The idea is the opposite , Each hexadecimal digit is converted to four binary digits , The order of operations is also from low to high . The following figure shows how to convert hexadecimal integers A5D6 Convert to binary :

As you can see from the diagram , Hexadecimal integer A5D6 The result of converting to binary is 1010 0101 1101 0110.
stay C In language programming , Binary system 、 octal 、 There is little conversion between hexadecimals , So here we only talk about the conversion of integers , It is enough for everyone to apply what they have learned . in addition , There is also very little direct conversion between octal and hexadecimal , We won't explain it here .
This article refers to the following documents , Predecessors summed up very well , In order to preserve , On the other hand, let yourself have a sorting process , I recorded this article .
Reference documents
边栏推荐
- Design of music box based on assembly language
- ZABBIX agent2 installation
- MySQL trigger
- Which domestic cloud management platform manufacturer is good in 2022? Why?
- MySQL log module of InnoDB engine
- Matlab imoverlay function (burn binary mask into two-dimensional image)
- How does MySQL execute an SQL statement?
- Multi table operation - Auto Association query
- Select drop-down box realizes three-level linkage of provinces and cities in China
- MySQL transaction
猜你喜欢

Read and understand the rendering mechanism and principle of flutter's three trees

Multi table operation - Auto Association query

Seven ways to achieve vertical centering

Mmclassification training custom data

Use and install RkNN toolkit Lite2 on itop-3568 development board NPU
![[superhard core] is the core technology of redis](/img/5e/d6438f09031c2acbea17441c316a2b.jpg)
[superhard core] is the core technology of redis

Redis's memory elimination mechanism, read this article is enough.

Matlab struct function (structure array)

Take you hand in hand to develop a service monitoring component

Hiengine: comparable to the local cloud native memory database engine
随机推荐
Understand kotlin from the perspective of an architect
byte2String、string2Byte
[pytorch pre training model modification, addition and deletion of specific layers]
Swift - add navigation bar
Redis highly available slice cluster
Want to ask, how to choose a securities firm? Is it safe to open an account online?
[untitled]
MySQL function
图像超分实验:SRCNN/FSRCNN
Tabbar configuration at the bottom of wechat applet
MVVM framework part I lifecycle
只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
强化学习-学习笔记3 | 策略学习
POJ-2499 Binary Tree
Principle and performance analysis of lepton lossless compression
Redirection of redis cluster
Codeworks 5 questions per day (1700 average) - day 5
MySQL constraints
Is investment and finance suitable for girls? What financial products can girls buy?
Hash tag usage in redis cluster