How to use Math related function calls?

steve2077
Posts: 4
Joined: Mon Feb 02, 2015 3:20 pm

How to use Math related function calls?

Postby steve2077 » Wed Mar 25, 2015 12:00 am

Hi there?

I would like to use some of math related function calls like pow, sin, sqrt...
But it seems math function doesn't work with SDK.
Either #include<math.h> on user_main or -lm on the Linker doesn't work too.
Do you have any idea to work them out?

Thanks

steve2077
Posts: 4
Joined: Mon Feb 02, 2015 3:20 pm

Re: How to use Math related function calls?

Postby steve2077 » Thu Mar 26, 2015 9:16 am

I have solved some part of it by simulating the math function though, still I would like to know how to link standard math.h or math library in sdk(if available)..
Thanks..

Code: Select all

double pow(double x,double y)
{
 double z , p=1;
 //y<0 ? z=-y : z=y ;
 if(y<0)
    z = fabs(y);
 else
    z = y;
 for(int i=0; i<z ; ++i)
 {
    p *= x;
 }
 if(y<0)
   return 1/p;
 else
   return p;
}

double fabs(double x)
{
 return( x<0 ?  -x :  x );
}

Who is online

Users browsing this forum: No registered users and 57 guests