---- 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.