Skip to main content
jjyeh1976
Associate III
Sep 4, 2009 5:18 AM UTC
Question

Math routine with Cosmic free 16k and STVD 4.1.2

Posted on September 04, 2009 at 07:18

Math routine with Cosmic free 16k and STVD 4.1.2

    This topic has been closed for replies.

    4 replies

    jjyeh1976
    jjyeh1976Author
    Associate III
    May 17, 2011 1:04 PM UTC
    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?

    jjyeh1976
    jjyeh1976Author
    Associate III
    May 17, 2011 1:04 PM UTC
    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
    jjyeh1976Author
    Associate III
    May 17, 2011 1:04 PM UTC
    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)

    luca239955_st
    Associate II
    May 17, 2011 1:04 PM UTC
    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 !