当前位置:网站首页>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
边栏推荐
- Website_ Collection
- TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
- 手写事件发布订阅框架
- Error in v-on handler: "typeerror: cannot read property 'resetfields' of undefined"
- Getting started with JDBC
- 拷贝构造函数 浅拷贝与深拷贝
- 线性代数感悟之1
- 【题解】[SHOI2012] 随机树
- Milvus 2.0 質量保障系統詳解
- Some problems encountered in recent programming 2021 / 9 / 8
猜你喜欢

Mock test using postman

Scope and scope chain in JS

Zhongang Mining: Fluorite Flotation Process

feign报400处理

Get the column name list of the table quickly in Oracle

Do you really understand the principle of code scanning login?

Idea of batch manufacturing test data, with source code

How much do you know about the process of the interview

The new MySQL table has a self increasing ID of 20 bits. The reason is

Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
随机推荐
Basic case of Baidu map
vscode如何比较两个文件的异同
How much do you know about the process of the interview
Read a blog, re understand closures and tidy up
Mock test
【WPF绑定3】 ListView基础绑定和数据模板绑定
Shortcut keys (multiline)
Feign report 400 processing
自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
Generate random numbers with high quality and Gaussian distribution
Summary of common websites
MySQL master-slave replication
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
◰GL-阴影贴图核心步骤
Baidu Map Case - Zoom component, map scale component
Modify the test case name generated by DDT
Net standard
1-4 configuration executable script of nodejs installation
Collect blog posts
1-3 nodejs installation list configuration and project environment