Just encountered a floating point accuracy issue. Anyone here knows why? Thanks a lot..,
I wrote a simple code using VDSP5 (newest update) and ran on ADSP-21479:
|float x, y, z;|
|for (x = 0; x<2*PI; x = x+ (1e-4))|
|y = sinf(x);|
|z = cosf(x);|
|MsgLen = sprintf (PrintMsg, "%f, %f, %f \r\n",x,y,z);|
Then I logged the data from UART. According to the code, x should be:
0, 0.0001, 0.0002, ...,
However what I got is:
0, 0.0001, 0.0002,..., 0.063200, 0.063301, 0.063401,..., 0.122202, ...,
the small error grows to some funny numbers like 0.432879,. which should never be seen.
The same code in Matlab, calculation result is correct.
we calculated some cosd() array in 21479 and found some funny numeric noise.., and then did this experiment.