Hi,
I am trying to use sin(), cos() and sqrt() functions from math.h in my project, and I got some weird behavior from them. Each time I run the program, these functions gave me different results for the same input data. The test code is as follows, all variables are floating type (32-bit):
dummy=1.234;
dummy1 = sin(dummy);
dummy2 = cos(dummy);
dummy3 = sqrt(dummy);
I first saw this problem with sqrt() that always gave incorrect results for any floating data with decimal, such as 1.2, 16.1, 0.09, etc, but correct results for integers like 16.0, 4.0, etc. Then I found that sin() and cos() were not working properly either. The results from sin() and cos() were kind of random, but some time (about 20% of time) they gave me correct results. As I added more code in the project, the results changed as well.
I tried the same test code on three board, two with MSP430F2274 and one with MSP430F1232. So far only the one with MSP430F1232 gave me correct calculation for all the functions. Besides the test code
I am wondering if this problem is somehow related to the execution of the run-time library. I search similar problem on E2E community and followed some instructions to check the memory location of the sin()/cos()/sqrt() function and make sure that they were intact in execution. They are actually intact.
I would really appreciate any suggestions on my problem!
Yang
