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


Groups > comp.lang.python > #79263 > unrolled thread

Re: Extract Indices of Numpy Array Based on Given Bit Information

Started byArtur Bercik <vbubbly21@gmail.com>
First post2014-10-18 16:02 +0900
Last post2014-10-18 16:02 +0900
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Extract Indices of Numpy Array Based on Given Bit Information Artur Bercik <vbubbly21@gmail.com> - 2014-10-18 16:02 +0900

#79263 — Re: Extract Indices of Numpy Array Based on Given Bit Information

FromArtur Bercik <vbubbly21@gmail.com>
Date2014-10-18 16:02 +0900
SubjectRe: Extract Indices of Numpy Array Based on Given Bit Information
Message-ID<mailman.14963.1413620435.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

So, the  Bit No. 2-5 for the following case is '1101', right?

1073741877: 1000000000000000000000000110101

 If my required bit combination for Bit No. 2-5 is '1011', then the above
number (1073741877) is not chosen, right??

Look forward to know your confirmation.

On Sat, Oct 18, 2014 at 3:50 PM, Chris Angelico <rosuav@gmail.com> wrote:

> On Sat, Oct 18, 2014 at 5:42 PM, Artur Bercik <vbubbly21@gmail.com> wrote:
> > I got some sense, but could not imagine if required Bit No. 2–5, and  Bit
> > Combination 0000.
> >
> > I hope example with the new case would make me more sense.
> >
>
> Just write the number in binary, with the bits you're interested in
> set to 1, and everything else 0:
>
> ... 876543210
> ... 000111100
>
> >>> 0b000111100
> 60
> >>> 1073741877 & 0b000111100
> 52
>
> So this number does _not_ have all zeroes there. If it did, the result
> would be zero. To look for some other pattern, just do the same thing
> - suppose we want to find numbers where it's 1001, we just look for
> the result to be 0b000100100, or 36.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web