Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79258
| References | <CA+F4vi=SMCNO-v55ZyKBau6+HAt=HPRYECnVkUr28wzgG3praA@mail.gmail.com> <CAPTjJmohbdOOn_Ug1iYBJO6NMoR944OY+ecUCamGO26hTNZEcA@mail.gmail.com> <CA+F4vinwQvNJWu2wkx_sr+xhTWJOvXtODb9PZH9vvYbSCG+1iQ@mail.gmail.com> |
|---|---|
| Date | 2014-10-18 17:50 +1100 |
| Subject | Re: Extract Indices of Numpy Array Based on Given Bit Information |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14958.1413615055.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Extract Indices of Numpy Array Based on Given Bit Information Chris Angelico <rosuav@gmail.com> - 2014-10-18 17:50 +1100
csiph-web