cancel
Showing results for 
Search instead for 
Did you mean: 

Math routine with Cosmic free 16k and STVD 4.1.2

jjyeh1976
Associate II
Posted on September 04, 2009 at 07:18

Math routine with Cosmic free 16k and STVD 4.1.2

4 REPLIES 4
jjyeh1976
Associate II
Posted on May 17, 2011 at 15:04

Hi,

I need the math function such atan() and acos(), but they seem not return a resonable value, my code

double v;

v = atan(0.2);

v = acos(0.3);

I observed the ''v'' in debug mode, but not a correct value of atan(0.2) or acos(0.3), what should I do to make these function work?

Jason

jjyeh1976
Associate II
Posted on May 17, 2011 at 15:04

answer my question...

in the ''Project Settings'' -> Linker -> User Defined options, add

''-lm'' will solve this problem.

but I find another problem, if I declare the v as local variable (in main.c), the returned value never correct, if it is declared as global variable, the returned value is correct, why?

luca239955_st
Associate III
Posted on May 17, 2011 at 15:04

>> if I declare the v as local variable (in main.c), the returned value never correct, if it is declared as global variable, the returned value is correct, why?

probably an optimization; the result should be correct even with a local variable, but you probably don't see it.

Regards,

Luca (Cosmic)

PS: I don't know what -lm is, but if it works, so be it !

jjyeh1976
Associate II
Posted on May 17, 2011 at 15:04

Hi Luca,

Thanks for your advisement, I will check for the optimiaztion.

BTW, the -lm is the linker command that to find the ''libm.xxx'' while

linking, the xxx is depends on platform. (In linux is .a)