[Numpy-discussion] inconsistent behavior in binary_repr

Damian Eads eads@soe.ucsc....
Wed Jun 4 02:56:30 CDT 2008


I noticed some odd behavior in binary_repr when the width parameter is 
used. In most cases it works,

In [23]: numpy.binary_repr(1, width=8)
Out[23]: '00000001'

In [24]: numpy.binary_repr(2, width=8)
Out[24]: '00000010'

In [25]: numpy.binary_repr(3, width=8)
Out[25]: '00000011'

In [26]: numpy.binary_repr(4, width=8)
Out[26]: '00000100'

except when 0 is passed, I get the following

In [27]: numpy.binary_repr(0, width=8)
Out[27]: '0'

Is this what the output is intended to be for the 0 case?


More information about the Numpy-discussion mailing list