当前位置:网站首页>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
边栏推荐
- Interface document yaml
- Idea of batch manufacturing test data, with source code
- Scope and scope chain in JS
- Freecodecamp ---- budget & category exercise
- El cascade and El select click elsewhere to make the drop-down box disappear
- Blue Bridge Cup provincial road 06 -- the second game of the 12th provincial competition
- Paging the list collection
- STM32__ 03 - beginner timer
- Go language RPC communication
- Input file upload
猜你喜欢
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
On lambda powertools typescript
Further study of data visualization
PyMySQL
. net cross platform principle (Part I)
Bytevcharts visual chart library, I have everything you want
EF core in ASP Generate core priority database based on net entity model
. net type transfer
Smart doc + Torna generate interface document
Bottom processing of stack memory in browser
随机推荐
Variable length parameter__ VA_ ARGS__ Macro definitions for and logging
Path environment variable
Lock lock
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Tencent resolves the address according to the IP address
SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
How much do you know about the process of the interview
[problem solving] [show2012] random tree
Promise (II)
1-2 characteristics of nodejs
Expression "func" tSource, object "to expression" func "tSource, object" []
Promise (I)
Detailed explanation of Niuke - Gloves
Promise (III)
Generation of barcode and QR code
Modify the test case name generated by DDT
Milvus 2.0 质量保障系统详解
CentOS MySQL multi instance deployment
True math problems in 1959 college entrance examination
JSON deserialize anonymous array / object