What is an efficient method to calculate the integer part of the base 2 logarithm of a floating point number? Something like
N = ceil( log2( f ))
N = floor( log2( f ))
The standard library function
frexp does exactly that: it decomposes a double into an integer exponent and a normalized mantissa.
If you are content with the floor of the logarithm, rather than rounding the logarithm to the nearest integer, you are probably better off with the newer standard library function
Note that these two functions treat zeros and infinities differently, so they are not quite interchangeable.