<div dir="ltr">Thanks Chris Angelico for your nice answer.<br>I got some sense, but could not imagine if required Bit No. 2–5, and  Bit Combination 0000.<div><br></div><div>I hope example with the new case would make me more sense.</div><div><br></div><div>Artur</div><div><div><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 18, 2014 at 3:24 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, Oct 18, 2014 at 4:58 PM, Artur Bercik <<a href="mailto:vbubbly21@gmail.com">vbubbly21@gmail.com</a>> wrote:<br>
> I want to get the index of my data where the following occurs:<br>
><br>
> Bit No. 0–1<br>
> Bit Combination: 00<br>
<br>
</span>So, what you want to do is look at each number in binary, and find the<br>
ones that have two zeroes in the last two places?<br>
1073741824: 1000000000000000000000000000000<br>
1073741877: 1000000000000000000000000110101<br>
<br>
The easiest way to do this is with simple bitwise operations:<br>
<br>
>>> 1073741824 & 3<br>
0<br>
>>> 1073741877 & 3<br>
1<br>
<br>
3 is 0000000000000011 in binary, so a bitwise AND with that will tell<br>
you about just the last two bits. The result will be an integer - 0,<br>
1, 2, or 3, representing 00, 01, 10, or 11 for those last two bits. So<br>
all you have to do is AND each number with 3, and when the result is<br>
0, that's what you want.<br>
<br>
Does that make sense?<br>
<br>
ChrisA<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>