Popular recipes tagged "float" but not "spread"http://code.activestate.com/recipes/tags/float-spread/2012-05-17T13:47:07-07:00ActiveState Code RecipesFunction that supports dividing timedelta by float (Python)
2012-05-17T13:47:07-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578136-function-that-supports-dividing-timedelta-by-float/
<p style="color: grey">
Python
recipe 578136
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/division/">division</a>, <a href="/recipes/tags/float/">float</a>).
</p>
<p>Python 2.x doesn't support dividing a timedelta by a float (only works with int). This function adds support for that.</p>
How to Mutate a Float (Python)
2012-05-14T16:49:13-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578132-how-to-mutate-a-float/
<p style="color: grey">
Python
recipe 578132
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/structure/">structure</a>).
</p>
<p>This is just an experiment to test my mental understanding of Python. It should not be used in any code as is violates the design principle that floats are to be immutable. The code also abuses <code>ctypes</code> and an understanding of how <code>floats</code> are currently arranged in memory. <code>set_float</code> is not guaranteed to work properly on any system, and may fail to work in the future if the data's arrangement changes.</p>
Floating point bitwise operations (Python)
2011-11-28T23:47:25-08:00Pyry Pakkanenhttp://code.activestate.com/recipes/users/4180119/http://code.activestate.com/recipes/577967-floating-point-bitwise-operations/
<p style="color: grey">
Python
recipe 577967
by <a href="/recipes/users/4180119/">Pyry Pakkanen</a>
(<a href="/recipes/tags/bitwise/">bitwise</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/floating/">floating</a>, <a href="/recipes/tags/point/">point</a>).
</p>
<p>Implements bitwise operations for real numbers by using an infinite one's complement representation.</p>
"Comma float" to float (Python)
2010-02-11T22:19:41-08:00Matevz Leskohttp://code.activestate.com/recipes/users/4173032/http://code.activestate.com/recipes/577054-comma-float-to-float/
<p style="color: grey">
Python
recipe 577054
by <a href="/recipes/users/4173032/">Matevz Lesko</a>
(<a href="/recipes/tags/comma/">comma</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/string/">string</a>).
Revision 2.
</p>
<p>Convert comma separated floating point number (12,3456) to float.</p>
Special Range Function for Different Kinds of Ranges (int, float, character) (Python)
2011-03-30T16:42:47-07:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577583-special-range-function-for-different-kinds-of-rang/
<p style="color: grey">
Python
recipe 577583
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/character/">character</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/integer/">integer</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/special/">special</a>).
Revision 3.
</p>
<p>This module allows the user to create a more verbose set of ranges. Simple character ranges, and float ranges are supported.</p>
<p>Supported Ranges:</p>
<ul>
<li>Basic Integer Ranges</li>
<li>Float Ranges (as accurate as a float range can get)</li>
<li>Simple character ranges (lowercase to lowercase, uppercase to uppercase, etc.)</li>
</ul>
<p>It should work in Python 2 and Python 3.</p>
<p><strong>If you tested this for speed, or want to test this for speed, please post the results! (And your system specs)</strong></p>
<p><strong>Edit:</strong> Found a really silly error of mine when using range instead of xrange in these functions!</p>
Improved range function (Python)
2010-06-07T01:50:20-07:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577256-improved-range-function/
<p style="color: grey">
Python
recipe 577256
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/replace/">replace</a>).
Revision 2.
</p>
<p>While using the built-in range function a while ago. I found an odd (perhaps bug) where the range function couldn't use float steps. I am not sure if that was intended for simplicity or not, but I wrote my own range function that goes beyond that anyway.</p>
Floating point range (Python)
2010-02-24T07:12:55-08:00Steven D'Apranohttp://code.activestate.com/recipes/users/4172944/http://code.activestate.com/recipes/577068-floating-point-range/
<p style="color: grey">
Python
recipe 577068
by <a href="/recipes/users/4172944/">Steven D'Aprano</a>
(<a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/maths/">maths</a>, <a href="/recipes/tags/range/">range</a>).
</p>
<p>Generator that produces floats, equivalent to range for integers, minimising rounding errors by using only a single multiplication and addition for each number, and no divisions.</p>
<p>This generator takes an optional argument controlling whether it produces numbers from the open, closed, or half-open interval.</p>