I'm just starting to use the bitarray package in python, and trying to make a bitarray from an integer gives me really confusing results:
>>> import bitarray
>>> bitarray.bitarray(5)
bitarray('01000')
>>> bitarray.bitarray(5)
bitarray('00010')
>>> bitarray.bitarray(5)
bitarray('00100')
>>> bitarray.bitarray(5)
bitarray('00110')
Does anyone have any idea why this would be happening??
Also: what would be a better way of making a bitarray from an int? This works, but string conversion seems like a strange way to do it...
>>> bitarray.bitarray(bin(5)[2:])
bitarray('101')
Edit: I ended up switching to bitstring, which does have an easy method of getting bitstrings from ints:
>>> bitstring.BitArray(uint=5,length=6)
BitArray('0b000101')