Top-rated recipes tagged "bits"http://code.activestate.com/recipes/tags/bits/top/2011-02-02T12:50:58-08:00ActiveState Code RecipesBitset (Python) 2009-05-04T16:37:02-07:00geremy condrahttp://code.activestate.com/recipes/users/4170000/http://code.activestate.com/recipes/576738-bitset/ <p style="color: grey"> Python recipe 576738 by <a href="/recipes/users/4170000/">geremy condra</a> (<a href="/recipes/tags/bits/">bits</a>, <a href="/recipes/tags/bytes/">bytes</a>). </p> <p>This is a simple Bitset type for Python. It implements the Sequence interface plus __setitem__, the set operations, and string and integer conversions.</p> interleave bits (aka morton-ize aka z-order curve) (Python) 2011-02-02T12:50:58-08:00Romain Dartigueshttp://code.activestate.com/recipes/users/4167472/http://code.activestate.com/recipes/577558-interleave-bits-aka-morton-ize-aka-z-order-curve/ <p style="color: grey"> Python recipe 577558 by <a href="/recipes/users/4167472/">Romain Dartigues</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/bits/">bits</a>, <a href="/recipes/tags/manipulation/">manipulation</a>, <a href="/recipes/tags/mathematical/">mathematical</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>This recipe let you encode in a single number two or three numbers.</p> <p>Note: this is only an adaptation of the recipes from <strong>Sean Eron Anderson</strong> and <strong>Fabian “ryg” Giesen</strong>; all credits goes to the respective authors.</p> <ul> <li><a href="http://graphics.stanford.edu/%7Eseander/bithacks.html#InterleaveBMN" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN</a></li> <li><a href="http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/" rel="nofollow">http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/</a></li> </ul>