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);
}
Magnus,
Well... I was skeptical at first....
Your code is indeed faster, but it is not outputting correct results, so
if you can tweak it to output correct results without sacrificing speed
I will indeed be impressed!
/me crosses fingers ;)
Royce3