Newsgroups: sci.math,sci.math.symbolic,sci.math.num-analysis,comp.lang.lisp,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!miner.usbm.gov!news.er.usgs.gov!news1.radix.net!news2.agis.net!agis!newspeer1.agis.net!agis!news.minn.net!visi.com!www.nntp.primenet.com!nntp.primenet.com!news.mathworks.com!enews.sgi.com!ix.netcom.com!hbaker
From: hbaker@netcom.com (Henry Baker)
Subject: Q: name of fcn to count low-order zeros in bin. # ??
Content-Type: text/plain; charset=ISO-8859-1
Message-ID: <hbaker-3101970800040001@10.0.2.1>
Sender: hbaker@netcom21.netcom.com
Content-Transfer-Encoding: 8bit
Organization: nil
X-Newsreader: Yet Another NewsWatcher 2.2.0
Mime-Version: 1.0
Date: Fri, 31 Jan 1997 16:00:04 GMT
Lines: 39
Xref: glinda.oz.cs.cmu.edu sci.math:183274 sci.math.symbolic:25202 sci.math.num-analysis:32866 comp.lang.lisp:25004 comp.lang.scheme:18309


I'm gathering a list of the _names_ used for the library function which
counts the number of low-order zeros in the binary representation of
an integer = the exponent of the largest power of 2 that divides the
integer.

For the moment, let us call this function 'foo(n)'.  Then

foo(1) = 0
foo(2) = 1
foo(3) = 0
foo(4) = 2
foo(5) = 0
foo(6) = 1
foo(m 2^k) = k if odd(m)
etc.

Note that 2^(foo(n)) = n AND (-n).

I know that the 'foo(n)' exists in every large symbolic and number theory
package under various different names.  What I am interested in is _what these
names are_.  Perhaps it is time to standardize on such a name.

---

In Common Lisp, there is a function 'integer-length', which is an approximation
to log2(n), but nothing corresponding to foo(n).

In Common Lisp, we can define

(defun foo (n) (- (integer-length (logand n (- n))) 1))

but this isn't an efficient method for calculating foo(n) for large
n, because it costs a lot to compute even when n is odd, and hence
foo(n) is trivially 0.

---

Thanks for your responses in advance.
