4. Fixed-point number simulation floating-point operation and the common strategy
I believe that we have already understood the general picture of floating-point number conversion to fixed-point count. In fact, the principle is very simple, really apply to the actual project, you may encounter a variety of problems. With my experience, the common strategies are as follows:
1) Division conversion to multiplication or shift operations
We know that no matter the hardware platform if the transformation, the division operation requires much more than multiplication and subtraction shift operations, especially in embedded applications, "efficiency" is particularly important. To the author's experience, in fact, a large part of the project Division operations can be converted into multiplication and shift operations, efficiency is still a lot of room for improvement.
2) look-up table calculation
Some operational expressions may involve a lot of headaches in the mathematical formula, especially on the embedded hardware platform, this formula is a headache, because the hardware-related software platform to provide a limited number of functions, and some do not have many "common" mathematical formulas such as the root. If this class of operations is rarely present in the project, and the number of its value is not much, then you can consider the various situations to be analyzed, the various possible results produced into a static table (can understand a number of groups), and then a simple conditional judgment statement can solve this type of problem.
3) Series expansion
The background of the problem with the above questions. For some mathematical formulas, if the range of values is not easy to handle, you can use series expansion mode.
4) Simultaneous change of numerator and denominator
For some division operations, in order to ensure accuracy, if the molecular expansion range is not large enough, you can consider narrowing the denominator, you can achieve the desired effect. A specific example can refer to my other article "solve a problem that has been bothering for 2 days, fixed point operation Problem".
The above is the entire content of this article, I hope to give you a reference, but also hope that we support the cloud habitat community.