当前位置:网站首页>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
边栏推荐
- Deep discussion on the decoding of sent protocol
- Matlab struct function (structure array)
- July Huaqing learning-1
- Learn the memory management of JVM 03 - Method area and meta space of JVM
- Third party payment interface design
- Just a coincidence? The mysterious technology of apple ios16 is actually the same as that of Chinese enterprises five years ago!
- Select drop-down box realizes three-level linkage of provinces and cities in China
- POJ-2499 Binary Tree
- Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
- Learn the garbage collector of JVM -- a brief introduction to Shenandoah collector
猜你喜欢
Multi table operation - sub query
Check the debug port information in rancher and do idea remote JVM debug
Get all stock data of big a
Why do you always fail in automated tests?
嵌入式软件架构设计-消息交互
Redis master-slave mode
HiEngine:可媲美本地的云原生内存数据库引擎
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
自动化测试生命周期
MySQL index (1)
随机推荐
MySQL storage engine
How to recover the information server and how to recover the server data [easy to understand]
July Huaqing learning-1
Solve the problem of cache and database double write data consistency
The evolution of mobile cross platform technology
只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
Interviewer: is acid fully guaranteed for redis transactions?
Flutter2 heavy release supports web and desktop applications
PXE启动配置及原理
Learn the memory management of JVM 03 - Method area and meta space of JVM
MySQL index (1)
MySQL constraints
Which domestic cloud management platform manufacturer is good in 2022? Why?
What is digital existence? Digital transformation starts with digital existence
Solve the error 1045 of Navicat creating local connection -access denied for user [email protected] (using password
Uniapp + unicloud + Unipay realize wechat applet payment function
查看rancher中debug端口信息,并做IDEA Remote Jvm Debug
Hash tag usage in redis cluster
Master the new features of fluent 2.10
ABAP table lookup program