问题描述:

I am working on a platform, which doesn't have the math library, but I need to use the logf function (natural log with floating point input). I tried to search the code for logf but in vain. Can somebody provide or give a link for logf function code.

网友答案:

If you don't have math library, you can go to libc to look for the code ->

http://sourceware.org/git/?p=glibc.git;a=blob;f=math/w_logf.c

And see how logf calls __ieee754_logf ->

http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/flt-32/e_logf.c

I hope it helps you.

网友答案:

I've seen a few references to logf() functions which just use casting around log(), such as:

float logf(float _X)
{
  return ((float)log((double)_X));
}

http://www.raspberryginger.com/jbailey/minix/html/lib_2math_2log_8c-source.html is an implementation of log() (though I have no personal experience with the function there, I merely found it while googling).

相关阅读:
Top