Category : C Source Code
Archive   : CSRC2.ZIP
Filename : LOG.C

 
Output of file : LOG.C contained in archive : CSRC2.ZIP
/* log - returns natural log and log base 10 */

/*
Based on Yale CS Dept C library.

Coefficients are #2705 from Hart & Cheney. (19.38D)

It calls frexp and itof.
*/

extern double frexp();
extern double itof();

static double log2 = 0.693147180559945309e0;
static double ln10 = 2.302585092994045684;
static double sqrto2 = 0.707106781186547524e0;
static double p0 = -.240139179559210510e2;
static double p1 = 0.309572928215376501e2;
static double p2 = -.963769093368686593e1;
static double p3 = 0.421087371217979714e0;
static double q0 = -.120069589779605255e2;
static double q1 = 0.194809660700889731e2;
static double q2 = -.891110902798312337e1;

double log(arg)

double arg;
{
double x,z,zsq,temp;
int exp;

if (arg <= 0.0)
return(-.99e30);
x = frexp(arg,&exp);
while (x < sqrto2)
{
x = x*2.0;
exp--;
}
z = (x-1.0)/(x+1.0);
zsq = z*z;
temp = ((p3*zsq+p2)*zsq+p1)*zsq+p0;
temp = temp/(((zsq+q2)*zsq+q1)*zsq+q0);
temp = temp*z+itof(exp)*log2;
return(temp);
}

double log10(arg)

double arg;
{
return(log(arg)/ln10);
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : LOG.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/