[Numpy-discussion] inconsistent behavior in binary_repr

Robert Kern robert.kern@gmail....
Wed Jun 4 02:59:35 CDT 2008


On Wed, Jun 4, 2008 at 2:56 AM, Damian Eads <eads@soe.ucsc.edu> wrote:
> Hi,
>
> 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?

No. SVN trunk seems to work correctly. What version of numpy do you have?

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list