Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'suppose': 0.07; 'bits': 0.09; 'cc:addr:python-list': 0.11; 'binary,': 0.16; 'did,': 0.16; 'sense,': 0.16; 'zero.': 0.16; 'zeroes': 0.16; '\xc2\xa0if': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'skip:1 30': 0.19; '>>>': 0.22; 'example': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'there.': 0.32; 'url:python': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'combination': 0.36; 'right?': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'so,': 0.37; 'pm,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'hope': 0.61; 'new': 0.61; 'no.': 0.61; 'numbers': 0.61; "you're": 0.61; 'more': 0.64; 'forward': 0.65; 'to:addr:gmail.com': 0.65; '2-5': 0.91; 'imagine': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=T4+fGpCA0V2/hk8sepWYG6NXSQd7JAvGCtEalrzYYqo=; b=ym+UCdqEvJJeqkMmICdwBeUpMVRSuQSXnqPA2qJ86r12XFF/9THnW3MxJhar7adshh G2kw36wwFFk7pckLCXHM0oh/kFab/QtSEs0unj+HYuJRSiVkIKVf21wfFdVRhYO71zA1 PiaStG1sYvq+DrFK0kwe5u10l+qHyJwIwHjZWKs7crrmrf9PAwfgW2MVME9ej5iLhSxN B00JG+PSvwrQuLmNteFPcsm9CFSekIsbD++JwkFXjD+QgY/iZ65pyaqxq781txI5ReA7 x7LqFOLtw6jDy+7ESLC1bZmVIUHzFCqBtdI4tARNUh0+TkbKdRP/vju/5Zbe7f5lwfUT K+Dg== X-Received: by 10.202.104.210 with SMTP id o79mr10468467oik.41.1413615765428; Sat, 18 Oct 2014 00:02:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Artur Bercik Date: Sat, 18 Oct 2014 16:02:25 +0900 Subject: Re: Extract Indices of Numpy Array Based on Given Bit Information To: Chris Angelico Content-Type: multipart/alternative; boundary=001a114098a08c20b10505ad1163 X-Mailman-Approved-At: Sat, 18 Oct 2014 10:20:33 +0200 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 102 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413620435 news.xs4all.nl 2962 [2001:888:2000:d::a6]:33823 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79263 --001a114098a08c20b10505ad1163 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 wrote: > On Sat, Oct 18, 2014 at 5:42 PM, Artur Bercik wrote= : > > I got some sense, but could not imagine if required Bit No. 2=E2=80=935= , 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 > --001a114098a08c20b10505ad1163 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
So, the=C2=A0=C2=A0Bit No. 2-5 for the following case is '1101', rig= ht?

1073741877: 1000000000000000000000000110101

= =C2=A0If my req= uired bit combination for=C2=A0Bit No. 2-5 is '1011', then the above number= (107374= 1877) is not chosen, right??

Look forward to know your confirmatio= n.

On Sat, Oct 18, 2014 at 3:50 PM, Chris Angelico <<= a href=3D"mailto:rosuav@gmail.com" target=3D"_blank">rosuav@gmail.com&g= t; 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=E2=80=93= 5, and=C2=A0 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

--001a114098a08c20b10505ad1163--