On Fri, Jan 28, 2011 at 02:02:36PM +0100, Philipp Überbacher wrote: > rant_begin > Why can't log mean the same thing everywhere? Why does it need to be > base e here and base 10 there? Why is there no consistency? > And why is there no proper logarithmus dualis function? Because you > can simply do log(n)/log(2)? We've just seen how well this works. > How about: > log() - base 10 > ln() - base e - logarithmus naturalis > ld() - base 2 - logarithmus dualis > rant_end Libm has log(), log10, and log2(). > The next obvious question is: Does the inaccuracy reliably result in > values bigger than 11? No. If the input is a power of two, and you expect an integer as a result, just do k = (int)(log2(x) + 1e-6) or k = (int)(log(x)/log(2) + 1e-6) or int m, k; for (k = 0, m = 1; m < x; k++, m <<= 1); which will round up if x is not a power of 2. Ciao, -- FA There are three of them, and Alleline. _______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx http://lists.linuxaudio.org/listinfo/linux-audio-user