当前位置:网站首页>[C language _ review _ learn Lesson 2] what is base system? How to convert between hexadecimals
[C language _ review _ learn Lesson 2] what is base system? How to convert between hexadecimals
2022-07-27 09:15:00 【Super Daxiong】
Review before class :C What kind of language is a language ? A High-level language 、B Low level language 、 C Semiotic language 、 D assembly language , I believe everyone will not be wrong .
Catalog
What is base ? Our life is full of happiness everywhere , One day is 24 Hours 、 An hour is 60 minute 、 One minute is 60 second 、 There are... On a Monday 7 God ........ Have you ever heard of the word "half weight" ? That is to say, buying half a kilo of things means eight Liang , One kilo is sixteen Liang , full 16 In one digit, this is hexadecimal . I'll be a primary school teacher today to test you ,5+8 How much ( I'm not kidding you ) You would say equal to 13, Your answer is decimal, that is, full decimal one , In the computer, the numbers are in binary ( Only 1 and 0) What is stored is full binary , Of course, there are octal ( from 0 To 7)、 Hexadecimal ( from 0 To F) It's all similar , Octal full eight into one digit , Hexadecimal full hexadecimal into one digit ( Where hexadecimal 10 use A To express ,11-B、12-C、13-D、14-E、15-F).
Let's start asking The conversion between various hexadecimals
Hexadecimal said B Binary system O or Q For octal 、D For decimal 、H For hexadecimal , You can also use corner markers (10)n Base number .
Convert decimal to binary :
Integer processing :
Convert decimal integers to binary integers. Convert decimal integers to binary integers using " except 2 Remainder , In reverse order " Law . The specific way is : use 2 Divide decimal integers , You can get a quotient and a remainder ; Reuse 2 Get rid of business , And you get a quotient and a remainder , Do so , Until the quotient is less than 1 Until , Then take the remainder as the low significant bit of the binary number , The remainder is the high significant bit of the binary number , Put them in order .

Decimal processing :
Decimal decimal is converted to binary decimal by “ ride 2 Sort by integer ( Sort in positive order ). practice : Multiply by... Using decimal decimals 2, Then take the whole number , Until the decimal place is 0 until , Of course, some decimals can't be divided completely. We can keep them according to the accuracy .

Binary to decimal
The binary conversion bit decimal system can use the method of weighted expansion in addition

If it's a decimal , Just follow -1 Power 、-2 Calculate in the order of power .
8421 Patchwork
Personal skills : We can use... When calculating binary conversion to decimal or decimal conversion to binary 8421 Patchwork .
8421 Patchwork : The bit on the left of binary is always twice the bit on the right , For example, binary 1 For decimal 1, Binary system 10 For decimal 2、 Binary system 100 For decimal 4、 Binary system 1000 For decimal 8, This is 8421 play . The left digit is twice as many as the adjacent right digit. We just need to remember the number above each digit to express the decimal system
128 64 32 16 8 4 2 1, In this way, we can easily express decimal . If decimal is converted to binary, then vice versa .
Convert decimal to octal
Converting decimal to octal is almost the same as converting decimal to binary , Ten to two yes " except 2 Remainder , In reverse order " Law . Ten to eight is divided by 8 Remainder , In reverse order .
The specific way is : use 8 Divide decimal integers , You can get a quotient and a remainder ; Reuse 8 Get rid of business , And you get a quotient and a remainder , Do so , Until the quotient is less than 1 Until , Then take the remainder as the low significant bit of the binary number , The remainder is the high significant bit of the binary number , Put them in order .

Octal to decimal :
The method of converting binary to decimal is the same , Expand by weight in the method of addition .

The conversion between decimal and hexadecimal is relatively simple
Ten to sixteen also use except 2 Remainder , In reverse order .
Sixteen to ten also uses the weighted expansion in addition method .
It should be noted that hexadecimal 10 use A Express , And so on !


Binary to octal
Three bit binary can represent one bit octal , We can use 421 Dafa ( Because octal can represent 0-7 Three bit binary can represent 0-7)

Octal to binary
As can be seen from the above, three bits of binary represents one bit of octal , One octal represents three binary .

Binary to hexadecimal
A four bit binary can represent one hexadecimal bit , We can use 8421 Dafa ( Because hexadecimal can represent 0-15 That is to say 0-F A four bit binary can represent 0-15)

Hexadecimal to octal
In the same way as octal, one hexadecimal represents four binary .

Be careful : Octal and hexadecimal cannot be converted directly , It needs to be converted to other base numbers first, and then converted
The ending egg :

Special for review
Cute new Blogger , If something goes wrong, please correct it . Thank you for your three company !
边栏推荐
- 【每日算法Day 94】经典面试题:机器人的运动范围
- CUDA programming-05: flows and events
- 软件测试功能测试全套常见面试题【功能测试-零基础】必备4-1
- 巴比特 | 元宇宙每日必读:广州南沙发布“元宇宙九条”措施,平台最高可获得2亿元资金支持...
- Principle of flex:1
- Save Xiaoyi from Netease written test -- a typical application of Manhattan distance
- Intel, squeezed by Samsung and TSMC, finally put down its body to customize chip technology for Chinese chips
- How to upload dynamic GIF map in blog
- D3.v3.js data visualization -- pictures and tips of force oriented diagram
- 8 kinds of visual transformer finishing (Part 2)
猜你喜欢
![[interprocess communication IPC] - semaphore learning](/img/47/b76c329e748726097219abce28fce8.png)
[interprocess communication IPC] - semaphore learning

Linux Installation and remote connection MySQL records

Restful

Is the operation of assigning values to int variables atomic?

npm install报错 强制安装

B tree

CUDA programming-01: build CUDA Programming Environment

【微服务~Sentinel】Sentinel之dashboard控制面板

MySQL transaction

08_ Service fusing hystrix
随机推荐
[daily algorithm 94] classic interview question: motion range of robot
Programming style
PVT的spatial reduction attention(SRA)
微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
8 kinds of visual transformer finishing (Part 1)
Restful
Antdesign a-modal自定义指令实现拖拽放大缩小
MATLAB data import -- importdata and load functions
Tensorflow loss function
Two tips in arkui framework
Explicit animation in arkui
网易笔试之解救小易——曼哈顿距离的典型应用
博客怎么上传动态gif图
Thermal renewal and its principle
Principle of flex:1
500报错
How to register code cloud account
Babbitt | yuan universe daily must read: Guangzhou Nansha released the "Yuan universe nine" measures, and the platform can obtain up to 200million yuan of financial support
DNS域名空间
PVT's spatial reduction attention (SRA)