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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,237 次查看
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???
标签 (1)
标记 (1)
0 项奖励
回复
1 回复

731 次查看
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 项奖励
回复