diff --git a/openair1/PHY/TOOLS/log2_approx.c b/openair1/PHY/TOOLS/log2_approx.c index acd1534857..5b4d069663 100644 --- a/openair1/PHY/TOOLS/log2_approx.c +++ b/openair1/PHY/TOOLS/log2_approx.c @@ -21,56 +21,46 @@ unsigned char log2_approx(unsigned int x) { + unsigned char l2 = 0; + unsigned int tmp = x >> 1; - int i; - unsigned char l2; + while (tmp) { + l2++; + tmp >>= 1; + } - l2=0; + if (l2) + l2 += (x >> (l2 - 1)) & 1; - for (i=0; i<31; i++) - if ((x&(1<> 1; - int i; - unsigned char l2; + while (tmp) { + l2++; + tmp >>= 1; + } - l2=0; + if (l2) + l2 += (x >> (l2 - 1)) & 1; - for (i=0; i<63; i++) - if ((x&(((long long int) 1)<