In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use fixed points in the representation of decimals". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use fixed points in the representation of decimals.
A large number of digital operations are often needed in digital signal processing, for example, the demodulation of digital signal needs to collect a large number of IQ data to demodulate it. In the actual research and learning, we generally use the rich software to provide us with convenient computing tools (Matlab, Python, etc.) in the operating system, which can easily deal with the digital signals we have studied. However, students who have studied computer principles or assembly language will know that the operation of data is ultimately completed on the computer hardware, and our data operation at the operating system level often means that we need to schedule a lot of resources.
Although the performance of today's computers has been very powerful, but for application-oriented products, its processor performance is often not comparable to that of computers.
Usually, in communication, image and other digital signal processing, the hardware chip is used for data operation (DSP, FPGA, etc.). The digital signal operation on this kind of hardware chip can improve the operation efficiency, which is also widely used in engineering applications.
In these processors, various kinds of data are often stored in the form of integers (for example, the storage of IQ values in communications). In fact, most of the data we need to calculate are decimals, so how to solve it? In general, we can express decimals by fixed points.
What is a fixed point?
Fixed point is called Fixed Point Number in English, and its key point is above the word "fixed and point", that is, when representing decimal data, the position of the decimal point has been agreed to be fixed in a certain position. Corresponding to the floating-point number, the position of the decimal point is not fixed, the floating-point number is not expanded yet.
Fixed number representation
In the fixed point, the decimal point can divide the data into integer and decimal parts, so we can agree on the different positions of the decimal point in the data to represent the decimals of different sizes and precision. For example, when the decimal point is agreed between the symbol and numeric places, it represents a pure decimal; when the decimal point is agreed at the end, it can represent a pure integer.
Pure decimal
Pure integer
How do you describe this rule of fixed points? In fact, we can use two ways to express:
The Q notation Qx,x represents the number of decimal places.
The S notation Sx.y,x represents the number of integer places and y represents the number of decimal places.
We know that unsigned integers and signed integers can be divided into unsigned integers and signed integers according to the existence of symbolic bits in the computer, and of course, fixed points can also be divided into:
Unsigned fixed points: unsigned bit
Signed fixed points: there are symbolic bits
Unsigned fixed point number
Unsigned fixed-point numbers, numeric values have no symbolic bits in all the binary bits of the word length in the machine, all are numeric bits. For example, the decimal 1.2 is converted to a fixed number of 16 places, and the position of the decimal point is agreed between the 14th and 15th digits.
Unsigned Q14
According to the calculation results, the decimal 1.2 can be represented by the unsigned fixed point number 19661 in Q14 format.
The unsigned fixed point is relatively simple, and there is no negative decimal; however, the signed fixed point is not so simple, because there are positive and negative numbers, and their calculation methods are not the same.
Original code, inverse code, complement code
Source code, inverse code, and complement code are basically mentioned in most books related to computer programming. Before learning signed fixed numbers, we need to review the original code, inverse code and complement code. Because the data is stored in the form of complement, before learning signed fixed points, it is necessary for us to review this part of the content.
Source code: the highest bit is used as a symbol bit (if there is no symbol, there is no symbol bit), and the other bits are data binary true absolute values. For example, the unsigned number 5 has an 8-bit binary source code of 0000 0101, the signed number 5 has an 8-bit binary source code of 0000 0101, and the signed number-5 has an 8-bit binary source code of 1000 0101.
Inverse code: the inverse code of a positive number is the original code itself, while the inverse code of a negative number has the same symbol bit on the basis of its original code, and other bits are inverted. For example, the unsigned number 5 has the inverse code of 0000 for the 8-bit binary number, the signed number 5 has the inverse code of 0000 0101 for the 8-bit binary number, and the signed number-5 has the inverse code of 1111 1010 for the 8-bit binary number.
Complement: the complement of a positive number is itself, and the complement of a negative number is to add 1 to its inverse code. For example, the unsigned number 5 has an 8-bit binary complement of 0000; the signed number 5 has an 8-bit binary complement of 0000 0101; and the signed number-5 has an 8-bit binary complement of 1111 1011.
For positive numbers
Original code = inverse code = complement code
For negative numbers
Anti-code = symbol bit unchanged, original code anti-complement code = anti-code + 1
Signed fixed point number
The number of signed fixed points requires a special data bit as the symbol bit. Usually, the 1 on the symbol bit represents a negative number, 0 represents a positive number, and the rest of the bits are numeric bits. For example, convert decimals 0.8 and-0.8 to fixed points in Q15 format.
Signed Q15
Find the fixed point of the positive number 0.8:
Find the fixed point of negative number-0.8:
In signed fixed points, it is important to note that the calculation of negative numbers is different from that of positive numbers.
At this point, I believe you have a deeper understanding of "how to use fixed points in the representation of decimals". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.