Newsgroups: comp.lang.lisp,sci.crypt,comp.lang.c
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!miner.usbm.gov!news.er.usgs.gov!jobone!news2.acs.oakland.edu!condor.ic.net!news.cic.net!feeder.chicago.cic.net!compuserve.com!www.nntp.primenet.com!nntp.primenet.com!news.maxwell.syr.edu!news.bc.net!unixg.ubc.ca!info.ucla.edu!ihnp4.ucsd.edu!newshub.nosc.mil!news!news
From: broman@Np.nosc.mil (Vincent Broman)
Subject: Re: Name for fcn to find first low-order '1' bit in integer
In-Reply-To: Ian_Miller@bifroest.demon.co.uk's message of Wed, 05 Feb 1997
	21:46:44 +0000
Message-ID: <3jvi85es6t.fsf@Np.nosc.mil>
Lines: 35
Sender: news@nosc.mil
Reply-To: broman@nosc.mil
Organization: Naval Command Control and Ocean Surveillance Center, RDT&E Div.
X-Newsreader: Gnus v5.1
References: <hbaker-0302971702490001@10.0.2.1> <32F79D23.74DA@smarts.com>
	<AF1EB044966814C6B@bifroest.demon.co.uk>
Distribution: inet
Date: Thu, 6 Feb 1997 17:54:18 GMT
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:25200 sci.crypt:61740 comp.lang.c:235323

-----BEGIN PGP SIGNED MESSAGE-----

> a function which provided the index to the first low-order 1 bit in an
> integer

Thanks for the code.  Perhaps the function could be called
"factors_of_2_count" or something.

What I have never seen, and would like, already has a usable name:
"floor_log2", but no good implementation for integers that I can come up with.
I.e., I want to be able to find the index of the highest-order one bit in
an integer.  (The implementation for floats is nearly trivial, of course. :-)

The only approach I've found is essentially a series of comparisons
that do a binary search for the logarithm base 256, then shift out all
but the top octet and do a direct lookup in a 256-entry table to
get the low-order 8 bits of the result.  The search part is unaesthetic, tho.

Any zippier suggestions?


Vincent Broman,  code D783 Bayside                       Email: broman@nosc.mil
Naval Command Control and Ocean Surveillance Center, RDT&E Div.
San Diego, CA  92152-6222,  USA                          Phone: +1 619 553 1641
=== PGP protected mail preferred.  For public key finger broman@np.nosc.mil ===

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMvoalmCU4mTNq7IdAQGj+QP/VWCoha5WxoEYuyHmZLoyDIwow41cIopn
uB4xPzHhYBciYx+yGm71MuMROaQ5IFni+38aMcJOAPFarbrbJPql25N60o1872Ux
z4gnRsnQbLcKS9mHfiM1lkjVbs/T6KpsD3PWgXnDvfwCuLA76DBobZUeIA6xcHh9
xBK6HlSXFZo=
=Uahp
-----END PGP SIGNATURE-----
