当前位置:网站首页>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
边栏推荐
猜你喜欢
Derivation of Σ GL perspective projection matrix
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
Detailed explanation of Milvus 2.0 quality assurance system
面试百分百问到的进程,你究竟了解多少
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
扫码登录的原理你真的了解吗?
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
Net standard
Milvus 2.0 détails du système d'assurance de la qualité
文件操作《二》(5000字总结篇)
随机推荐
线性代数感悟之2
Change the password after installing MySQL in Linux
【解决报错】Error in v-on handler: “TypeError: Cannot read property ‘resetFields’ of undefined”
New keyword learning and summary
Expression "func" tSource, object "to expression" func "tSource, object" []
Linux MySQL data timing dump
websocket
JS to find the character that appears three times in the string
JS, entries(), keys(), values(), some(), object Assign() traversal array usage
Collect blog posts
PostgreSQL column storage and row storage
正则过滤内网地址和网段
织梦DEDECMS安全设置指南
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
About stream flow, write it down briefly------
Generation of barcode and QR code
[registration] tf54: engineer growth map and excellent R & D organization building
groutine
Milvus 2.0 質量保障系統詳解
El date picker limits the selection range from the current time to two months ago