Coyote's Guide to IDL Programming

Calculating the Log Base 2 of a Number

QUESTION: How can I calculate the Log Base 2 of a number or vector in IDL?

ANSWER: This answer provided by Martin Leuthi and Med Bennett on the IDL newsgroup.

The logarithm base N of any number is the natural logarithm of the number divided by the natural logarithm of the base. For example, here is a program named ALOG2 to calculate the base 2 logarithm of a number or vector:

   FUNCTION ALOG2, x
      RETURN, ALOG(x) / ALOG(2)
   END

Google
 
Web Coyote's Guide to IDL Programming