[Python-ideas] Float range class

Chris Barker chris.barker at noaa.gov
Fri Jan 9 23:37:56 CET 2015

On Fri, Jan 9, 2015 at 2:17 PM, Andrew Barnert <
abarnert at yahoo.com.dmarc.invalid> wrote:

> This is equivalent on designing float.__eq__ as something like
> abs(self-other) < 0.00000001. At first glance it seems like that makes all
> floating point comparison problems go away, until you try it with small
> floats and suddenly 9e-12 - 1e-12 == 4e-12.
> The right epsilon to use depends on the specific problem space, so it
> can't be hardcoded into a general-purpose function.

You could scale the epsilon with step, and get closer to general purpose.
but then you STILL might not get exactly what was expected.

Making an fp range an attractive nuisance.

And I still think most people actually want linspace(), anyway...

Note that a closed interval version with a specified delta could be handy,
but not hard to just compute the number of elements if you want.



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150109/a25bcbb5/attachment.html>

More information about the Python-ideas mailing list