Click here to Skip to main content
15,867,594 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Natural Logarithms and Exponent

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
17 Jan 2012CPOL 9.3K   2   2
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.



C#
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.)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO VISION fOr VISION
Belgium Belgium
I fell into applied algorithmics at the age of 16 or so. This eventually brought me to develop machine vision software as a professional. This is Dreamland for algorithm lovers.

Comments and Discussions

 
GeneralExcellent!!! I saw several posts about CORDIC functions, bu... Pin
Jacob F. W.18-Jan-12 18:34
Jacob F. W.18-Jan-12 18:34 
GeneralRe: Too glad that you liked these. The given implementation IS ... Pin
YvesDaoust18-Jan-12 22:17
YvesDaoust18-Jan-12 22:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.