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

Royce Mitchell III royce3 at ev1.net
Wed Mar 23 14:47:52 CET 2005


Mike Nordell wrote:

>int highest_bit(unsigned int i)
>{
>    int temp;
>    int ret = 0;
>    temp = i > 0xffff; i >>= 16*temp; ret = 16*temp;
>    temp = i > 0xff;   i >>=  8*temp; ret += 8*temp;
>    temp = i > 0xf;    i >>=  4*temp; ret += 4*temp;
>    temp = i > 0x3;    i >>=  2*temp; ret += 2*temp;
>    ret += (i>>1);
>    return ret;
>}
>  
>
This is almost, but not quite, 50% slower in msvc6 w/ "compile for 
speed". :(

Perhaps the reordering could help...



More information about the Ros-dev mailing list