Suppose I define some bitarray in python using the following code:
from bitarray import bitarray
d=bitarray('0'*30)
d[5]=1
How can I convert d to its integer representation?
In addition, how can I perform manipulations such as d&(d+1)
with bitarrays?
int.from_bytes(d.tobytes)
, but I don't have a way to check this. You might have to fiddle with the endian-ness of thebitarray
. – Asexual