当前位置:网站首页>Conversion between binary, octal, decimal and hexadecimal (integer plus decimal)
Conversion between binary, octal, decimal and hexadecimal (integer plus decimal)
2022-06-10 10:41:00 【Qin Xuexue】
List of articles
Preface
From now on, for some reason, I want to start learning C Language , Today, the first class that the teacher talked about was decimal calculation . This knowledge point has not been reviewed for a long time , Simply write an article blog Help the brain recall and consolidate .
One 、 Hex brief overview

It can be used Co., LTD. The number symbol of represents be-all Values are Carry system / Position counting method A major feature of the counting method , So it's also called Carry notation / Bit counting .
For any system —X Base number , It means that the number operation on each bit is every X Into one . Decimal system It's every decimal , Hexadecimal It's one every sixteen , Binary system It's two in one , And so on ,x The base is the square x carry .
# Overview from Baidu Encyclopedia
For any number , We can use different carry systems to express . such as : Decimal number 57(10), It can be used Binary system Expressed as 111001(2), It can also be used. Pental Expressed as 212(5), It can also be used. octal Expressed as 71(8)、 Expressed in hexadecimal as 39(16), The values they represent are the same .
Two 、 Common base division methods
The system that we usually encounter the longest in our life or study is Decimal system 、 Binary system 、 octal 、 Hexadecimal , But this is just a common base , It doesn't mean that there are only these bases , There are also some unusual base numbers , Like a year 12 Months , Isn't that what 12 Base number Well . One day 24 Hours , No, it is. 24 Base number Well , Here we focus on common base numbers .

So here comes the question , How to distinguish this modo base ??? a number 100, It can be decimal 100, It can also be binary 4 etc. , Very unclear , That's why we have the following Two ways to distinguish :
The first way is Numeric subscript notation , Well understood. , This / The number of strings is in decimal , You just put this / String numbers are enclosed in parentheses , Then identify the corresponding hexadecimal digit at the right subscript of the parenthesis .
for example (1421)10 For decimal ,(11001)2 For binary ,(672534)8 For octal ,(A3CE45)16 For hexadecimal .
The second way is English suffix capital letters , This is the same as Numeric subscript notation The same , It's just that the subscript numbers have become the English initials of each hexadecimal , Here we are required not to memorize words , However, we must find out which base is represented by the capital initial at the beginning of each base .
Binary system B (binary)
octal O (octal)
Decimal system D (decimal)
Hexadecimal H (hexadecimal)Be careful : When there are no subscript numbers and uppercase hexadecimal initials
The default is decimal .for example (1421) For decimal ,(11001)B=11001B For binary ,(672534)0=672534Q For octal ( If you don't write parentheses, put O Change it to Q, To prevent and 0 Mingle ),(A3CE45)H=A3CE45H For hexadecimal .
3、 ... and 、 Non decimal to decimal
Conversion between different bases , It's essentially Conversion between cardinalities , The method of non decimal to decimal is consistent , That is to count each of you According to the right Expand , also Add to sum Can .
Do you still don't understand , Just look at a few examples ( The words are a little ugly )
eg1. Convert binary to decimal

eg2. Convert octal to decimal

eg3. Convert hexadecimal to decimal

After writing, I suddenly saw that there was a decimal from non decimal to decimal , It's actually the same as an integer , Only the first digit after the decimal point becomes x-1, The second digit after the decimal point becomes x-2, And so on ……
eg4.
Four 、 Decimal to non decimal ( Integer plus decimal )
Decimal to non decimal , It's a little different from the previous one , Decimal to non decimal requires The integer part and the decimal part are converted respectively , The splicing shall be carried out after the conversion .
The integer part and the decimal part are converted respectively There must be some conversion skills , The conversion formula is Integral part : Turn and divide , Take the rest , The fractional part : Turn a few times a few , Just take the whole .
eg1. Decimal to binary ( Integers and decimals )

eg2. Decimal to hexadecimal ( Integers and decimals )

notes : Some regulations are accurate to the number of digits , There's no need to leave 0 until , When the accuracy is reached
5、 ... and 、 Binary to octal 、 Hexadecimal ( Integer plus decimal )
Binary to octal 、 Hexadecimal, that is, binary to 2~n~ Base number , We can convert binary to decimal , Then convert the decimal system to octal 、 Hexadecimal , It's just a little slow and low.
Binary to 2n Base number , There is also a separate method , Take binary numbers with integers and decimals for example , That's it Take the decimal point as the boundary Grouping , Integer parts from right to left , The decimal part is from left to right , Every time ~n~ The number of digits is a group ( Not enough decimals n Bit is required 0 Fill up enough n position , Integers don't matter ), Then divide into each group Then calculate according to binary , Last Summarize the splice , We can get the result .
I don't say much nonsense , Let's look at an example ……
eg1. Convert binary to octal

eg2. Convert binary to hexadecimal

6、 ... and 、 octal 、 Hexadecimal to binary ( Integer plus decimal )
Binary to 2~n~ Base number and 2~n~ Base number Converting to binary is actually a Reciprocal processes ,2~n~ Base number Change to binary , Each value of itself can be converted to n Bit binary number represented by binary and spliced .
eg1. Convert octal numbers to binary numbers

eg2. Convert a hexadecimal number to binary

边栏推荐
- Delphi中的冷门知识点
- 常用Shell命令 - 02 压缩和解压缩
- 二进制、八进制、十进制、十六进制间互转(整数加小数)
- Detailed steps for installing mysql+django under mac
- “隔离险”成“网红”产品,不少投保者却表示:理赔难
- "Great freehand flower and bird painting master Mr. likuchan" blockbuster digital collection launched in the whole network
- Dr. jiangxiaowei, a member of hpca Hall of fame, is the chief scientist of Dayu smart core
- ColorUI配色详情
- Stock to maximize profits
- Phpstorm configuration database connection
猜你喜欢

NFT链游GameFi系统开发,元宇宙游戏搭建

Leetcode 1991. Find the middle position of the array (brute force enumeration)

For details of imitated Taobao products, pull down to switch to picture details, and pull up to switch to graphic introduction

ColorUI配色详情

今天19:30 | 图形学专场——中国科学院计算技术研究所高林老师团队

安装CocoaPods最新版教程
![[497. random points in non overlapping rectangles]](/img/c7/5e3e7bf1a78332aff4d2d42d6f826e.png)
[497. random points in non overlapping rectangles]

山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(十六)

EG2131测试电路

Phpstrom uploads the project to the code cloud
随机推荐
最近几篇较好论文实现代码(附源代码下载)
ColorUI配色详情
Drawing curve with MATLAB
How to choose cities, schools and majors for the college entrance examination?
Leetcode 2000. Reverse word prefix
Hardcore spoiler! With 11 topics and 14 celebrities, dragon dragon dragon community entered Intel meetup and announced the agenda!
9、 Delegation mode
PV操作每日一题-橘子苹果问题(初阶版)
uniapp消息推送(个推-PHP服务端推送)
混音器:视频会议录制不可或缺的组件
MySQL Foundation
PAT 甲级 1134 顶点覆盖
数组判断任意出现的重复值
“会说话的汤姆猫家族-时代逐光者”3D数字藏品中奖名单公布
How to state clearly and concisely the product requirements?
Today, 19:30 | graphics special session - Gao Lin, teacher team of Institute of computing technology, Chinese Academy of Sciences
Xcode8.3.2 自动打包脚本
[untitled]
「诗经」主题文化数字藏品中奖名单公布
【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结