Problems with automatic data type conversion during DSP debugging

Source: Internet
Author: User

 

---- Peng Xiaolin

196568501 (qq) Welcome

 

Problem description:

Void test (float data)
{
Float copydata = Data * 1000*1000;
U64 intcopydata = copydata;
// View the intcopydata Value
}

Main ()
{
Test ();
}

Check the value of intcopydata and find that the value is different from the theoretical value by several thousand. Changing copydata to double is not acceptable.

 

Solution:

 

I carefully read the DSP compiler manual and found that the compiler sets float and double types to 32 float (hard floating point) by default to improve instruction execution speed ), the maximum supported floating point number is 64-bit (soft floating point ).

The C language standards are different. The manual provides two solutions:

Solution 1:

Solve the problem by setting preprocessing options. However, after changing the project preprocessing option (set to 64-bit), a warning is issued during connection, prompting that the floating point width in the. o file is inconsistent. Carefully analyze the warning information and find that the library files that come with the compiler are all compiled based on 32-bit floating point. Finally, I gave up this solution (after all, it is hard to work with the boss and get it quickly ).

Solution 2:

A table is provided in the compiler manual. Set the copydata declarative long double.

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.