On Fri, Jan 28, 2011 at 02:02:36PM +0100, Philipp Überbacher wrote:
> rant_begin
Libm has log(), log10, and log2().
> The next obvious question is: Does the inaccuracy reliably result in
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@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-user
LINUX® is a registered trademark of Linus Torvalds in the USA and other countries.
Linuxaudio.org logo copyright Thorsten Wilms © 2006.
Hosting provided by the Virginia Tech Department of Music and DISIS.