Bitwise OR?

Clemens Hepper ethrandil at gmx.net
Fri Mar 24 12:27:26 CET 2006


To look at the bit-structure i've implemented a little function:

def bitstring(number, digits=32):
  """lsb------>msb"""
  result = ""
  for a in xrange(digits):
    if number & 1:
      result += '1'
    else:
      result += '0'
   number >>= 1
  return result

I wonder if there is something like sizeof() for int numbers.

mfg
- eth



More information about the Python-list mailing list