Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.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.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'referring': 0.07; 'typed': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'marker': 0.16; 'match:': 0.16; 'quoted': 0.16; 'right:': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'skip:1 30': 0.19; 'written': 0.21; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; "i've": 0.25; '>': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'url:wiki': 0.31; 'context,': 0.31; 'url:wikipedia': 0.31; 'text': 0.33; 'url:python': 0.33; 'something': 0.35; 'case,': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'combination': 0.36; 'false': 0.36; 'right?': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'so,': 0.37; 'sometimes': 0.38; 'skip:& 10': 0.38; 'thank': 0.38; 'convention': 0.38; 'needed': 0.38; 'list,': 0.38; 'pm,': 0.38; 'mailing': 0.39; 'called': 0.40; 'url:mail': 0.40; 'most': 0.60; 'no.': 0.61; "you're": 0.61; "you'll": 0.62; 'more': 0.64; 'forward': 0.65; 'to:addr:gmail.com': 0.65; 'underneath': 0.84; 'absolutely': 0.87; '2-5': 0.91 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=v/XbZHLLxZkgKsDrjikK/i1goDmONd9qP92YpFwobFM=; b=kvxPdCz7iyzQWrh1Rj5XBMm54JGPIj936Oj55vFmw/1NPzmxPLQ1pQmYhZqSY5NfOz /PsEFYBAeYE9KHhIVtz21YFLB16m1sJrKWXAarWIUDadVoV4OdFhJvtitp9YBi37dyXY 0t3cjymrlPQCIhHHWPG9tgL5lP0VUFVGKjPHmfr/pczh01a+ZR7UebL1lH5ElhJtFjOp 8Jhb36xBxz5yrFj4byTNvfL7fOWG+0HLAqTFE1VT9pNvWhj73wdKia6slU4UvTV/OQgR ALYw7yeGFUS212P3yQuPUeq5LT+WujXYoUyi10m867/FxDKu1P6s4Krk39YxSWlo58XQ 02oA== X-Received: by 10.202.84.77 with SMTP id i74mr10621047oib.29.1413616882876; Sat, 18 Oct 2014 00:21:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Artur Bercik Date: Sat, 18 Oct 2014 16:21:02 +0900 Subject: Re: Extract Indices of Numpy Array Based on Given Bit Information To: Chris Angelico Content-Type: multipart/alternative; boundary=001a113b09382708970505ad54d2 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: 134 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413620435 news.xs4all.nl 2964 [2001:888:2000:d::a6]:33824 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79265 --001a113b09382708970505ad54d2 Content-Type: text/plain; charset=UTF-8 On Sat, Oct 18, 2014 at 4:10 PM, Chris Angelico wrote: > On Sat, Oct 18, 2014 at 6:02 PM, Artur Bercik 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 > --001a113b09382708970505ad54d2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On S= at, Oct 18, 2014 at 4:10 PM, Chris Angelico <rosuav@gmail.com> wrote:
On Sat, Oct 18, 2014 at 6:0= 2 PM, Artur Bercik <vbubbly21@gma= il.com> wrote:
> So, the=C2=A0 Bit No. 2-5 for the following case is '1101', ri= ght?
>
> 1073741877: 1000000000000000000000000110101
>
>=C2=A0 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 maili= ng
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#Interleave= d_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<= br> 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) =3D=3D 0b101100
False
>>> (1073741869 & 0b111100) =3D=3D 0b101100
True

Thank you very much Chris Angelico, I h= ave come to know it.



=C2= =A0

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

--001a113b09382708970505ad54d2--