[Computer Basics] I talked about the data representation roughly
Part of the information involved in the article comes from the Internet, and of course, there are my own personal summaries and opinions. The purpose of sharing is to build a community and consolidate myself. If the quoted material is infringing, please contact me to delete it! Fortunately I am here, thank you for coming!
💿 Learn to learn and start rewinding! If I can't learn new things, I will learn the basics! I review the past and learn more!
(Don’t make trouble, it’s actually a weak foundation. I wrote this more lou summary before, now I’m going to change my homework and make a correction and summary)
Data in the computer
The data in the computer is stored in binary, and the binary has only two states, which are very good representations, not very (Ginkgo), very mechanical.
The above is the binary number, can you understand it? (Computer: Yes!)
Secretly give me the conversion formula of the hexadecimal number. If there is a better one, please remember to comment to me.
- The principle of R system: advance every R
- Convert R to Decimal: Expand by right
- Decimal to R system: short division
For general data processing point of view, then, it is from
type of data,
range of data,
accuracy of the data, then in the computer, but also consider
storage, and data
Several representations of data
How can computer learners have never heard of the four major codes of original code, inverse code, complement code, and shift code? I'm sorry, the four major codes.
Before looking at the four major codes, take a step to understand what the true value is.
Literally, the real value!
In fact, in actual calculations, after getting a number, it will be converted into binary for calculation. But the actual value is divided into
binary is called 161bde26d7261b truth value.
- is the sign bit of
−5 // 真值 -101 +5 // 真值 +101
Let's look at a formula first
0 1 represent the sign bit on the basis of the truth value. generally stipulates that 0 represents a positive number and 1 represents a negative number . en, is it wrong? It seems to be the case, mark it up and take the test!
−5 // 真值 -101 // 原码 1101 +5 // 真值 +101 // 原码 0101
Come up with a formula
The inverse code of the positive number in the formula is the original code, and the inverse code of the negative number is the sign bit unchanged, and the rest of the bits are inverted bit by bit.
−5 // 真值 -101 // 原码 1101 // 反码 1010 +5 // 真值 +101 // 原码 0101 // 反码 0101
The old rules, look at the formula first.
The complement of a positive number is equal to the original code of the positive number, and the complement of a negative number is equal to the inverse code + 1.
−5 // 真值 -101 // 原码 1101 // 反码 1010 // 补码 1011 +5 // 真值 +101 // 原码 0101 // 反码 0101 // 补码 0101
The complement code solves the problem of calculating the sign bit of the original code and the inverse code, so the computer usually uses the complement code to calculate!
It means that the floating-point number needs to use the form of shifting code, come, look at the formula!
Code shifting generally uses double sign bits in operations, that is, the highest bit is filled with 0, if it is a positive number, the next highest bit is 1; if it is a negative number, the next highest bit is 0.
In fact, the sign bit of the complement code is inverted, the value bit remains unchanged, and the obtained number is the code shift.
−5 // 真值 -101 // 原码 1101 // 反码 1010 // 补码 1011 // 移码 00011 +5 // 真值 +101 // 原码 0101 // 反码 0101 // 补码 0101 // 移码 01101
Type of data
This is not the data type of a certain programming language!
Here mainly introduces fixed-point numbers and floating-point numbers.
fixed-point number is a number with a fixed decimal point, which is divided into fixed-point integer and fixed-point decimal, which depends on what the decimal point means. The decimal point is fixed at the last position, which is called a fixed-point integer, and in other positions it is a fixed-point decimal.
The indicated data range is insufficient, and the word length of the computer is fixed. After the position of the decimal point is determined, the number of digits after the decimal point is also fixed, so some high-precision data cannot be represented.
In order to solve the problem of precision, floating-point numbers came out. floating-point number represents a number whose decimal point is not fixed.
Remember, the basics of computers are not over yet! Just wait and see! (Don’t dare, look forward to your next reading)
Public Account-Guizimo, Mini Program-Xiaogui Blog
If you feel helpful to you, please give me a thumbs up 👍, keep paying attention!