当前位置:网站首页>[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 !
边栏推荐
- CUDA programming-01: build CUDA Programming Environment
- Thermal renewal and its principle
- js call和apply
- Sharing of four open source face recognition projects
- Wechat applet 5 - foundation strengthening (not finished)
- Mangodb simple to use
- 5g failed to stimulate the development of the industry, which disappointed not only operators, but also mobile phone enterprises
- Matlab drawing skills and examples: stackedplot
- Matlab uses m file to produce fuzzy controller
- [daily algorithm day 96] Tencent interview question: merge two ordered arrays
猜你喜欢

PyTorch自定义CUDA算子教程与运行时间分析

Can "Gulangyu yuancosmos" become an "upgraded sample" of China's cultural tourism industry

Deep understanding of Kalman filter (1): background knowledge

Understand various IOU loss functions in target detection

Antdesign a-modal user-defined instruction realizes dragging and zooming in and out

ES6 new - array part

Ctfshow ultimate assessment

罗克韦尔AB PLC 通过RSLinx Classic与PLC建立通信的具体方法步骤

How to optimize the deep learning model to improve the reasoning speed

js call和apply
随机推荐
ctfshow 终极考核
npm和yarn 更新依赖包
Antdesign a-modal自定义指令实现拖拽放大缩小
如何注册码云账号
pollFirst(),pollLast(),peekFirst(),peekLast()
The lifecycle of arkui development framework components
D3.v3.js data visualization -- pictures and tips of force oriented diagram
函数防抖节流
As a VC, the auction house invested Web3 for the first time
async/await的执行顺序以及宏任务和微任务
Encountered 7 file(s) that should have been pointers, but weren‘t
Rewrite the tensorrt version deployment code of yolox
Matlab drawing skills and examples: stackedplot
Deep understanding of Kalman filter (2): one dimensional Kalman filter
Pymongo fuzzy query
Unity3d 2021 software installation package download and installation tutorial
[I2C reading mpu6050 of Renesas ra6m4 development board]
Linux Installation and remote connection MySQL records
Storage and computing engine
HUAWEI 机试题:火星文计算 js