need a function
Brendan McKay
bdm at cs.anu.edu.au
Sat Jun 14 09:35:29 CEST 2008
Thanks, but I am looking for something that is not a loop (unrolled
or not) or involves a table lookup. The fact that it only needs to
work for powers of 2 should make it easier. Just the existence is
not interesting, I'm hoping for something _simple_.
Brendan,
* Max Alekseyev <maxale at gmail.com> [080614 17:13]:
> Take a look at:
> http://aggregate.org/MAGIC/#Log2%20of%20an%20Integer
> http://www.cs.utk.edu/~vose/c-stuff/bithacks.html#IntegerLogObvious
> http://www.jjj.de/bitwizardry/bitwizardrypage.html
> etc.
>
> Regards,
> Max
>
> On Fri, Jun 13, 2008 at 11:09 PM, Brendan McKay <bdm at cs.anu.edu.au> wrote:
> > Hi seqfans. This little problem might amuse someone and the answer
> > might even be useful.
> >
> > We are considering arithmetic in the non-negative integers mod 2^32.
> > The problem is, define a function f(n) using only +-*/ (where / throws
> > away the remainder) such that f(2^i) = i for i=0,1,...,31.
> >
> > If that is too onerous, you can also use bit-wise boolean operations.
> >
> > The corresponding problem for 2^64 is also of interest.
> >
> > Cheers, Brendan.
> >
More information about the SeqFan
mailing list