Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/05/07 08:25
Read: times


 
#145450 - Fixed-point log2, without lookup table.
Responding to: ???'s previous message
A while ago, I was looking for an algorithm that calculates a log2 without using a lookup table (we needed to free memory, but had plenty of CPU cycles).

I found one that is similar to integer square root algorithms - it calculates the integer part of the log2 by simply counting the leading zeros, and then adds the fractional part bit by bit by squaring the value, checking whether it's > 2, and setting the bit in question and dividing the working value by 2 if it is.

Of course, this algorithm has some limits (most notably numeric precision, since you keep squaring a value and truncating the result), but overall it delivered good precision for up to 16 output bits. It's also a bit of a CPU hog due to the number of multiplications required (one per output bit).


List of 30 messages in thread
TopicAuthorDate
1) Log computation, 2) LCD requirement            01/01/70 00:00      
   Yes            01/01/70 00:00      
      Why would you doubt it?            01/01/70 00:00      
      Yes            01/01/70 00:00      
         Doesn't have to be floating point            01/01/70 00:00      
            's the one            01/01/70 00:00      
               the good old Intel FP51 package            01/01/70 00:00      
         Should be in high level language, thanks..            01/01/70 00:00      
            you can steal it...            01/01/70 00:00      
               need floating-point log? - YES            01/01/70 00:00      
                  Fixed point ?            01/01/70 00:00      
                     RE: Fixed point ?            01/01/70 00:00      
                        And what is the input voltage range?            01/01/70 00:00      
                           RE: Aside: dB equivalent of voltage            01/01/70 00:00      
                              my point is...            01/01/70 00:00      
                                 Who remembers log tables?            01/01/70 00:00      
                              Already answered            01/01/70 00:00      
                        So use cB instead!            01/01/70 00:00      
                        Aside: dB equivalent of voltage            01/01/70 00:00      
   How to find log in assembly?            01/01/70 00:00      
      Hint            01/01/70 00:00      
      Math            01/01/70 00:00      
   Log calculation in ASM            01/01/70 00:00      
      Implementation and precision            01/01/70 00:00      
         Correct precision            01/01/70 00:00      
            Brilliant work            01/01/70 00:00      
               Absolutely!            01/01/70 00:00      
   Fixed-point log2, without lookup table.            01/01/70 00:00      
      To Mr Franck            01/01/70 00:00      
         Source for the algorithm.            01/01/70 00:00      

Back to Subject List