Getting at the bits of a 32-bit integer

Grant Edwards grante at visi.com
Wed Aug 25 11:45:11 EDT 2004


On 2004-08-25, Scott David Daniels <Scott.Daniels at Acm.Org> wrote:
> Grant Edwards wrote:
>
>>... That's a bit, um, conceited.  Somebody's got to twiddle all
>> those low-level bits out there to provide the infrastructure
>> that makes the world run.
>> 
>> I'm one of those people, and I need to do bit-twiddling quite
>> often while implimenting various communications protocols.
>
> If you are interested in such things, take a look at:
>
>      http://members.dsl-only.net/~daniels/bits.html
>
> It lets you do things like look at bit-ranges of (int, long, float)
> and find things like msb, lsb, particular bits (bit) and
> extract bit ranges.

That looks handy.

The other thing that looks very useful is a module posted a few
weeks back that impliments fixed-length numbers.  In addition
to manipulating individual bits, one often needs to do
operations on binary, two's compliment numbers of known, fixed
lengths.

-- 
Grant Edwards                   grante             Yow!  Yes, Private
                                  at               DOBERMAN!!
                               visi.com            



More information about the Python-list mailing list