On Sat, Aug 03, 2002 at 12:07:30PM -0400, Ken Fox wrote:
> Nicholas Clark wrote:
> >It seems that foo & (foo - 1) is zero only for a power of 2 (or foo == 0) 
> >but is there a fast way once you know that foo is a power of 2, to find out
> >log2 foo?

The ARM doesn't have a find first set bit instruction ?

This code includes 3 different ways of finding log2.
 
http://www.ddj.com/ftp/2001/2001_07/aa0701.txt

I believe the LOOKUP method was the fastest for me on SPARC, if I recall
correctly.

-- 
Jason

Reply via email to