Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70714

Re: Convert numpy array to single number

From Tom P <werotizy@freent.dd>
Newsgroups comp.lang.python
Subject Re: Convert numpy array to single number
Date 2014-04-29 17:42 +0200
Message-ID <bs9vipF2h3pU1@mid.individual.net> (permalink)
References <088cdf75-f196-404b-ba77-567559f431d8@googlegroups.com>

Show all headers | View raw


On 28.04.2014 15:04, mboyd02255@gmail.com wrote:
> I have a numpy array consisting of 1s and zeros for representing binary numbers:
>
> e.g.
>
>       >>> binary
>       array([ 1.,  0.,  1.,  0.])
>
> I wish the array to be in the form 1010, so it can be manipulated.
>
> I do not want to use built in binary converters as I am trying to build my own.
>

Do you mean that each element in the array represents a power of two?
So array([ 1.,  0.,  1.,  0.]) represents 2^3 + 2 = 6 decimal?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Convert numpy array to single number mboyd02255@gmail.com - 2014-04-28 06:04 -0700
  Re: Convert numpy array to single number Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-28 14:16 +0000
  Re:Convert numpy array to single number Dave Angel <davea@davea.name> - 2014-04-28 15:19 -0400
  Re: Convert numpy array to single number Tom P <werotizy@freent.dd> - 2014-04-29 17:42 +0200
    Re: Convert numpy array to single number Papp Győző <pappgyozo@gmail.com> - 2014-05-01 15:26 +0200

csiph-web