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,232件の閲覧回数
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 返信

726件の閲覧回数
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 件の賞賛
返信