[Numpy-discussion] convert integer into bit array

Nikolas Tautenhahn virtual at gmx.de
Mon May 16 14:55:30 EDT 2011


Hi,

for some research, I need to convert lots of integers into their bit
representation - but as a bit array, not a string like
numpy.binary_repr() returns it.

So instead of
In [22]: numpy.binary_repr(23)
Out[22]: '10111


I'd need:
numpy.binary_magic(23)
Out: array([ True, False,  True,  True,  True], dtype=bool)

is there any way to do this efficiently?

best regards,
Nik



More information about the NumPy-Discussion mailing list