[ros-dev] ping Alex regarding log2() for scheduler

Royce Mitchell III royce3 at ev1.net
Wed Mar 23 16:19:14 CET 2005


Royce Mitchell III wrote:

> Magnus Olsen wrote:
>
>> Hi I have not test run this code. But i think this form maby are 
>> faster that v3 of  Royce  Mitchell III code it leave to the compiler 
>> to optimze it more or I complete wrong
>> int highest_bit ( unsigned int i )
>> {
>>     int ret = 0;
>>     int n ;
>>     int t;
>>     int x;
>>
>>    for (t = 0; t>3;t++)
>>   {
>>      x = (16 << t);
>>      n = i >> x;
>>     if ( n )  i = n, ret  += x ;
>>   }
>>      return ret + (i>>1);
>> }
>>
>>  
>>
Unfortunately your code is broken in a couple ways, most notably the 
code inside the for() statement never executes. When I fix it to work 
correctly, it takes almost 3x longer than my code :(



More information about the Ros-dev mailing list