当前位置:网站首页>Conversion between hexadecimal numbers
Conversion between hexadecimal numbers
2022-04-23 17:05:00 【begeneral】
1、 Decimal to binary
Decimal to binary has 2 Ways of planting , The first is to divide the decimal number by 2, The remainder until the end is 0 perhaps 1, Then arrange the remainder of the last result from high to low , If the number of digits is not enough , High compensation 0.
Like decimal numbers 9:
9/2=4 more than 1
4/2=2 more than 0
2/2=1 more than 0
So the binary is :0000 1001. This is a mention , Because the divisor is 2, So the result of the last division can only be 0 perhaps 1, be equal to 0 The case is that the divisor is 1 perhaps 0, That is to say 1/2 or 0/2, Other decimal numbers and 2 The end of division
The result is 1.
This method only applies when the decimal number is small , When decimal numbers are large , Except it's not very convenient . At this time, you can first convert the decimal system to hexadecimal , Then convert hexadecimal to binary , This method will be introduced below .
2、 Decimal to hexadecimal
The principle of decimal to hexadecimal is the same as that of decimal to binary , Is to divide this decimal number by 16, Arrange the remainder from high to low .
Like decimal numbers 100:
100/16=6 more than 4
because 6 Less than 16 You don't have to go any further except , The result is 0x64. Let's look at a bigger number , Decimal number :5000
5000/16=312 more than 8
312/16=19 more than 8
19/16=1 more than 3
So the result is 0x1388.
3、 Hexadecimal to decimal
In hexadecimal A、B、C、D、E、F Decimal 10、11、12、13、14、15
This conversion is the method of converting decimal to hexadecimal, and vice versa , Multiply the number in the hexadecimal digit by the corresponding 16 To the power of , such as :0x3E
0x3E=3*16^1+14*16^0=3*16+14*1=48+14=62
Another example is the need to 2 Hexadecimal number in bytes :0x36BC
0x36BC=3*16^3+6*16^2+11*16^1+12*16^0=3*4096+6*256+11*16+12*1=14012
4、 Hex to binary
Every number in hexadecimal is a percentage of 4 A bit of , Convert this number into 4 Bit binary number can convert a hexadecimal number into binary .
such as :0x5F
5=4+1=2^2+2^0=0101
F=8+4+2+1=2^3+2^2+2^1+2^0=1111
So the result is 0101 1111
Just now it was said that when converting a large decimal number into binary , First convert it to hexadecimal , Then convert hexadecimal to decimal .
Because divided by 16 It's definitely better than dividing by 2 The number of times to be less , And it is more convenient to convert hexadecimal to binary , So I think it will be more efficient .
版权声明
本文为[begeneral]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554082018.html
边栏推荐
- Detailed explanation of the penetration of network security in the shooting range
- . net cross platform principle (Part I)
- 1-2 characteristics of nodejs
- Summary of common websites
- Calculation formula related to tolerance analysis
- SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
- JS, entries(), keys(), values(), some(), object Assign() traversal array usage
- Promise (I)
- Modify the test case name generated by DDT
- 面试百分百问到的进程,你究竟了解多少
猜你喜欢
Shell script -- shell programming specification and variables
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
SQL database
Mock test
groutine
1-4 configuration executable script of nodejs installation
文件操作《二》(5000字总结篇)
The new MySQL table has a self increasing ID of 20 bits. The reason is
PyMySQL
On lambda powertools typescript
随机推荐
Input file upload
STM32__ 03 - beginner timer
【WPF绑定3】 ListView基础绑定和数据模板绑定
PostgreSQL列存与行存
[registration] tf54: engineer growth map and excellent R & D organization building
How vscode compares the similarities and differences between two files
EF core in ASP Generate core priority database based on net entity model
Get the column name list of the table quickly in Oracle
Basic case of Baidu map
Promise (II)
SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
freeCodeCamp----shape_ Calculator exercise
杂文 谈谈古典的《拆掉思维里的墙》
Copy constructor shallow copy and deep copy
Milvus 2.0 质量保障系统详解
El cascade and El select click elsewhere to make the drop-down box disappear
Solution architect's small bag - 5 types of architecture diagrams
Your brain expands and shrinks over time — these charts show how