bit shifting question
David Eppstein
eppstein at ics.uci.edu
Mon May 17 22:53:00 EDT 2004
In article <40a92d88$1 at nntp0.pdx.net>,
Scott David Daniels <Scott.Daniels at Acm.Org> wrote:
> Unfortunately, shifting is one of those places you
> can still discover the "width" with code like:
>
> def wordwidth():
> for shift in range(256):
> if 1 << shift < 0:
> return 1 + shift
Of course this will give a warning in 2.3 and fail to work in 2.4...
I wish I could get the 2.4 behavior now with a from __future__ import
but I don't see one for this, instead I find myself doing 1L<<shift a
lot.
--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
More information about the Python-list
mailing list