当前位置:网站首页>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
边栏推荐
- Learn JVM garbage collection 02 - a brief introduction to the reference and recycling method area
- [pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
- 【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
- Course design of compilation principle --- formula calculator (a simple calculator with interface developed based on QT)
- Flutter2 heavy release supports web and desktop applications
- MySQL log module of InnoDB engine
- MySQL splits strings for conditional queries
- Matlab struct function (structure array)
- How to clear floating?
- 查看rancher中debug端口信息,并做IDEA Remote Jvm Debug
猜你喜欢

Simple production of wechat applet cloud development authorization login

Take you hand in hand to develop a service monitoring component

mysql拆分字符串做条件查询

嵌入式软件架构设计-消息交互

Check the debug port information in rancher and do idea remote JVM debug

Get data from the database when using JMeter for database assertion
The survey shows that traditional data security tools cannot resist blackmail software attacks in 60% of cases

Understand redis persistence mechanism in one article

Four operations and derivative operations of MATLAB polynomials

强化学习-学习笔记3 | 策略学习
随机推荐
Why do you always fail in automated tests?
What is the difference between canvas and SVG?
ZABBIX agent2 installation
Principle of persistence mechanism of redis
MySQL trigger
Codeforces Round #804 (Div. 2)
Redis highly available sentinel cluster
手机 CPU 架构类型了解
查看rancher中debug端口信息,并做IDEA Remote Jvm Debug
Is investment and finance suitable for girls? What financial products can girls buy?
图像超分实验:SRCNN/FSRCNN
Want to ask, how to choose a securities firm? Is it safe to open an account online?
Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises
[HDU 2096] 小明A+B
Interviewer: is acid fully guaranteed for redis transactions?
Error modulenotfounderror: no module named 'cv2 aruco‘
Multi table operation - Auto Association query
Redis cluster (master-slave) brain crack and solution
Swift - add navigation bar
Matlab boundarymask function (find the boundary of the divided area)