Log2 Algorithm

The integer part of a binary logarithm can be found use the find first put operation on an integer value, or by looking up the exponent of a floating point value. Historically, the first application of binary logarithms was in music theory, by Leonhard Euler: the binary logarithm of a frequency ratio of two musical tones gives the number of octaves by which the tones differ. The modern form of a binary logarithm, using to any number (not exactly powers of two) was considered explicitly by Leonhard Euler in 1739.As part of his work in this area, Euler published a table of binary logarithms of the integers from 1 to 8, to seven decimal digits of accuracy. Euler established the application of binary logarithms to music theory, long before their applications in information theory and computer science became known.

Log2 source code, pseudocode and analysis