Floating-point fixed-point operation in DSP--subtraction operation of fixed-point number _c language

Source: Internet
Author: User

3. Subtraction operation of fixed-point number

Simply put, the principle of the various operations is to be the operation of the data to enlarge a certain number of times, in the process of operation of the magnified data, in the final need to output the results of the adjustment back.

For example, there are the following operations:

Copy Code code as follows:
...

COEFS1 = 0.023423; coefs2=0.2131

float COEFS1,COEFS2;

int result;

...

result = 34* coefs1+72* coefs2;

...

The code means that the module needs to output an integer result, but there are floating-point operations in the calculation. This code cannot be run if it is in a fixed-point DSP.

In order to solve this problem, we can do this: first of all, the COEFS1,COEFS2 and other similar floating-point data to expand a certain number of multiples (the specific expansion of how many times, according to the accuracy requirements of different), we temporarily move the decimal point to the right 4 digits, that is, the increase of multiples: * 10000, in the final output of the time in narrowing the same multiple. The modified code is roughly as follows:

Copy Code code as follows:
COEFS1 = 234; Coefs2= 2131

int COEFS1,COEFS2;

int result;

...

result = 34* coefs1+72* coefs2;

Result/= 10000;

...

Of course, the above example for everyone to understand, write may not be too correct, but the basic essence should be these. The specific processing process, we can search the Internet "3rd Chapter DSP Chip fixed-point operation. doc" This article, write very specific, here no longer wordy.

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.