65.9K
CodeProject is changing. Read more.
Home

Natural Logarithms and Exponent

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Jan 17, 2012

CPOL
viewsIcon

9973

You should be delighted by the CORDIC approach to elementary functions computation.http://drdobbs.com/184404244[^]log10(x){ z = 0; for ( i=1; i= 1) x = x - x*2^(-i); z = z - log10(1-2^(-i)); else x = x + x*2^(-i); ...

You should be delighted by the CORDIC approach to elementary functions computation.

log10(x){
   z = 0;
   for ( i=1; i=<B; i++ ){
      if (x > 1)
         x = x - x*2^(-i);
         z = z - log10(1-2^(-i));
       else
         x = x + x*2^(-i);
         z = z - log10(1+2^(-i));
   }
   return(z)
}

(In this listing, B is the desired number of bits of resolution in the result.)