The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-02-2008
return_user return_user is offline
Registered User
 

Join Date: Dec 2007
Posts: 11
what is wrong with the log function in c?

Hi I looked up the reference but couldn't figure out whats wrong with my log funtions in ANSI C, need this log functions for a memory compiler, please help!!

#include <stdio.h>
#include <math.h>


int main(void)
{

double d ;

double logB(double x, double base);

printf(" natural log :\n");
for ( d = 1; d <= 10; d++)
printf(" ln(%f) = %f\n", d, log(d));

printf("\n\n\n 2base log :\n");
for ( d = 1.0; d <= 10.0; d++)
printf(" log2(%f) = %f\n", d, logB(d, 2));

return 0;
}

double logB(double x, double base) {
return( log(x) / log(base));
}
Reply With Quote
Forum Sponsor