As we all know, a computer is composed of hardware and software. The hardware system consists of five parts: the host, controller, memory, input device, and output device. The host and controller are integrated into one chip, it makes us familiar with CPU. but today we are going to discuss not these things, but the representation of data and text in the computer. You may immediately think: Will this still be discussed, it's just some numbers and English letters! No, I can only say that you have broken the pattern!
People who have been familiar with know that the computers we use only know 0 and 1, and all others know nothing about Chinese, English, and fanwenshenma. How do we see the 13145201314 numeric string and various texts? This is a question worthy of consideration and research by everyone studying computer technology.
Let's take a look at the simplest number. In the form of computer numbers, various numeric values are called machine numbers, also known as machine codes. They are counted in binary notation. The numbers are represented by 0 and 1, while decimal points are implicitly represented without occupying the actual location. The actual value corresponding to the number of machines is called the true value of the number.
Data format
1 fixed point
As the name suggests, it means that the decimal point of all data in the machine is fixed. Since the decimal point is specified, the solid point "." is no longer used. Theoretically, the decimal point can be fixed to which even, but the data is usually expressed as a pure decimal or a pure integer.
The number of fixed points indicates that the range of numbers is limited by the length of the word, indicating that the range of numbers is limited, and the accuracy is also limited. Therefore, in the machine, fixed point pure integer representation is often used.
2 floating point number
Given that floating point numbers can represent a relatively small range of values, and it is easy to overflow because the results are out of the range, a floating point number is introduced, that is, the number of decimal points is not fixed, the value range is larger.
The floating point representation format is as follows:
IEEE 754 is an industrial standard for floating point numbers developed by IEEE and is widely used. The standard representation is as follows:
What is the data range of floating point numbers?
Number of machine codes
How do I express the symbol bits when performing operations on data in a computer? Are you also involved in the operation with the value bit? If I participate in the operation, what will happen to the operation? To properly handle these problems, a variety of representation methods, such as source code, complement code, anti-code, and transfer code, are generated to encode the symbol bit and value bit together to represent the corresponding number. In order to distinguish between the number represented by writing and the number represented by these codes in the machine, the former is usually called the true value, and the latter is called the machine number or machine code.
1 original code
2. Reverse code
3. Complement
4 shift Codes
The following uses a fixed-point Integer as an example to describe the range and possible digital combination of the original code, reverse code, and complement value in the form of a number axis.
We also take a decimal Integer as an example to show its binary and representation of its various codes. You can think about and find out the rule from it.
In conclusion, we can come to the following conclusions:
1 is a positive integer. When expressed with the original code, reverse code, or complementary code, the sign bit is fixed to 0, and the digital value expressed in binary is the same, that is, the three representation methods are the same;
2 is a negative integer. When expressed with the original code, reverse code, or complementary code, the symbol bit is fixed as 1, and the digital values expressed in binary are different. The rules for changing from the original code representation to the complement code representation are as follows:
(1) the original code symbol bit is 1, and each binary digit of the integer returns an inverse code.
(2) The bitwise of the anticode symbol remains the same as 1, and the bitwise of the anticode value is added with 1.
3 from the 0 representation in the above table, we can see that 0 has two types of representation in the source code and the reverse code, while in the complement and transfer code, it is uniquely encoded;
4 The difference between the value of the complement and the value of the integer is only because the symbol bit is different.
If you encounter problems with the operation of various code systems, we will study them in detail again.
Preparing for the soft exam (1) Data Representation of computer composition principles