Popular Python recipes tagged "integers"http://code.activestate.com/recipes/langs/python/tags/integers/2017-03-12T23:10:48-07:00ActiveState Code RecipesNumber of bits needed to store an integer, and its binary representation (Python) 2017-03-12T23:10:48-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580762-number-of-bits-needed-to-store-an-integer-and-its-/ <p style="color: grey"> Python recipe 580762 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/formats/">formats</a>, <a href="/recipes/tags/integers/">integers</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/representation/">representation</a>, <a href="/recipes/tags/type/">type</a>). </p> <p>This recipe shows how to find, via Python code, the number of bits needed to store an integer, and how to generate its binary representation. It does this for integers from 0 to 256.</p> <p>More details and full output here:</p> <p><a href="https://jugad2.blogspot.in/2017/03/find-number-of-bits-needed-to-store.html" rel="nofollow">https://jugad2.blogspot.in/2017/03/find-number-of-bits-needed-to-store.html</a></p> Convert Spelled out Integers (e.g. three thousand two hundred fifty) into Integers (e.g. 3250) and Vice Versa (Python) 2016-07-14T21:08:01-07:00Chathura Gunasekarahttp://code.activestate.com/recipes/users/4194443/http://code.activestate.com/recipes/580689-convert-spelled-out-integers-eg-three-thousand-two/ <p style="color: grey"> Python recipe 580689 by <a href="/recipes/users/4194443/">Chathura Gunasekara</a> (<a href="/recipes/tags/integers/">integers</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/strings/">strings</a>). </p> <p>-Provides an isNumber function that can test if a floating point number is a number -str_to_int can convert a spelled out integer (e.g. 'one hundred thirty five') to its numeric form (e.g. 135) -int_to_str can convert an integer into its spelled out form.</p> Convert Spelled out Integers (e.g. three thousand two hundred fifty) into Integers (e.g. 3250) and Vice Versa (Python) 2016-06-09T20:35:26-07:00Brandon Martinhttp://code.activestate.com/recipes/users/4194238/http://code.activestate.com/recipes/580679-convert-spelled-out-integers-eg-three-thousand-two/ <p style="color: grey"> Python recipe 580679 by <a href="/recipes/users/4194238/">Brandon Martin</a> (<a href="/recipes/tags/integers/">integers</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/strings/">strings</a>). </p> <p>-Provides an isNumber function that can test if a floating point number is a number -str_to_int can convert a spelled out integer (e.g. 'one hundred thirty five') to its numeric form (e.g. 135) -int_to_str can convert an integer into its spelled out form.</p> Converting arbitrary size Python integers to packed binary data strings (Python) 2009-01-16T13:27:29-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576617-converting-arbitrary-size-python-integers-to-packe/ <p style="color: grey"> Python recipe 576617 by <a href="/recipes/users/4124829/">David Moss</a> (<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/integers/">integers</a>, <a href="/recipes/tags/pack/">pack</a>, <a href="/recipes/tags/struct/">struct</a>, <a href="/recipes/tags/unpack/">unpack</a>, <a href="/recipes/tags/unsigned/">unsigned</a>). </p> <p>Routines for converting <strong>large</strong> unsigned arbitrary sized Python integers to packed binary data strings and vice versa.</p>