Pre-ci test passed git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4000 818b1a75-f10b-46b9-bf7c-635c3b92a50f
31 lines
469 B
C
31 lines
469 B
C
unsigned char log2_approx(unsigned int x) {
|
|
|
|
int i;
|
|
unsigned char l2;
|
|
|
|
l2=0;
|
|
for (i=0;i<31;i++)
|
|
if ((x&(1<<i)) != 0)
|
|
l2 = i+1;
|
|
//l2 = i;
|
|
|
|
// printf("log2_approx = %d\n",l2);
|
|
return(l2);
|
|
}
|
|
|
|
unsigned char log2_approx64(unsigned long long int x) {
|
|
|
|
int i;
|
|
unsigned char l2;
|
|
|
|
l2=0;
|
|
for (i=0;i<63;i++)
|
|
if ((x&(((long long int) 1)<<i)) != 0)
|
|
// l2 = i+1;
|
|
l2 = i;
|
|
|
|
// printf("log2_approx = %d\n",l2);
|
|
return(l2);
|
|
}
|
|
|