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


Groups > comp.lang.python > #79265

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

References (1 earlier) <CAPTjJmohbdOOn_Ug1iYBJO6NMoR944OY+ecUCamGO26hTNZEcA@mail.gmail.com> <CA+F4vinwQvNJWu2wkx_sr+xhTWJOvXtODb9PZH9vvYbSCG+1iQ@mail.gmail.com> <CAPTjJmqkvC-yoBbsudk8y3tZ53Afbg38g3Aj0ffg21yBfwZ4Pg@mail.gmail.com> <CA+F4vimo358APcgCsPBAwzfDBcBFNczk=YD7+ODNtY2n9sEN_w@mail.gmail.com> <CAPTjJmppVp=0JN6ZT68jBNdBw7pevCHjUkO=9gxxHyFAawVGmA@mail.gmail.com>
From Artur Bercik <vbubbly21@gmail.com>
Date 2014-10-18 16:21 +0900
Subject Re: Extract Indices of Numpy Array Based on Given Bit Information
Newsgroups comp.lang.python
Message-ID <mailman.14964.1413620435.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

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

> On Sat, Oct 18, 2014 at 6:02 PM, Artur Bercik <vbubbly21@gmail.com> wrote:
> > 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.
>
> (Side point: Please don't top-post. The convention on this mailing
> list, and most other technical mailing lists, is what's sometimes
> called "interleaved style"; you trim the quoted text to what's needed
> for context, and put your text underneath what you're referring to.
> See https://en.wikipedia.org/wiki/Posting_style#Interleaved_style for
> more info.)
>
> >>> 1073741877&60
> 52
> >>> bin(52)
> '0b110100'
>
> Everything I've written with the triple-angle-bracket marker can be
> typed in at the Python prompt, and you'll see exactly what it does. In
> this case, you can see that you're absolutely right: 1073741877 has
> 1101 in those positions, so if you're looking for 1011, it won't
> match:
>
> >>> 0b101100
> 44
>
> However, 1073741869 would:
>
> >>> 1073741869&60
> 44
>
> The way to test would be something like this:
>
> >>> (1073741877 & 0b111100) == 0b101100
> False
> >>> (1073741869 & 0b111100) == 0b101100
> True
>

Thank you very much Chris Angelico, I have come to know it.





>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Thread

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

csiph-web