当前位置:网站首页>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
边栏推荐
- Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises
- Learn the memory management of JVM 03 - Method area and meta space of JVM
- ZABBIX customized monitoring disk IO performance
- Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
- PXE startup configuration and principle
- Solution to order timeout unpaid
- Principle of persistence mechanism of redis
- Linux安装部署LAMP(Apache+MySQL+PHP)
- How can beginners learn flutter efficiently?
- MySQL trigger
猜你喜欢
强化学习-学习笔记3 | 策略学习
什么是数字化存在?数字化转型要先从数字化存在开始
Matlab struct function (structure array)
Master-slave mode of redis cluster
The evolution of mobile cross platform technology
About cache exceptions: solutions for cache avalanche, breakdown, and penetration
Automated test lifecycle
How to clear floating?
Understand redis persistence mechanism in one article
July Huaqing learning-1
随机推荐
2022年国内云管平台厂商哪家好?为什么?
【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
MySQL storage engine
Master the new features of fluent 2.10
Seven ways to achieve vertical centering
Linux安装部署LAMP(Apache+MySQL+PHP)
GPS数据格式转换[通俗易懂]
MySQL splits strings for conditional queries
MySQL regular expression
7月华清学习-1
Image hyperspectral experiment: srcnn/fsrcnn
Matlab imoverlay function (burn binary mask into two-dimensional image)
Codeworks 5 questions per day (1700 average) - day 5
Course design of compilation principle --- formula calculator (a simple calculator with interface developed based on QT)
【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
MySQL multi table operation
Matlab boundarymask function (find the boundary of the divided area)
How to clear floating?
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"