Math.Sin Function Not Working for some values of the input argument

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Math.Sin Function Not Working for some values of the input argument

1,229 Views
studentLwatch
Contributor I

Hi,

 

I'm using CodeWarrior v 5.9.0 and DSP board MC56F8037

 

 

I'm trying to calculate Sin(arg) and Cos(arg) (to get parameters for FFT analysis)

 

 

for (k = 1; k < transformLength; k++) 
                    {
                  
                  arg = 2*(float)bin*M_PI*(float)k / (float)transformLength;
                  sinPart = sinPart+(inputData[k] * sign * sin(arg);
                  cosPart = cosPart + (inputData[k] * cos(arg));
                 }
The problem is sin(arg) works fine for many values of arg, but for some values of arg it gives TOTALY different output values and destroys all the calculations furhter on.
Example
In CodeWarrior when i debug(having imported Math.h) i get
sin(11.584)=0.968
When i calculate on the calculator (as well as try to calculate in c sharp coded program) It gives
sin(11.584) = -0.828
This is such a huge difference...and it happens for random samples.
For other samples like sin(5.694)=-0.555 both in COdeWarrior and C Shapr the values are the SAME. 
THIS has been really really driving me crazy.
Please, Could you look at this ... Is this a bug???
Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

723 Views
CrasyCat
Specialist III

Hello

 

I would recommend you to submit a service request to get support people looking at that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.

CrasyCat

0 Kudos
Reply