[Python-ideas] Floating point "closeness" Proposal Outline

Nathaniel Smith njs at pobox.com
Wed Jan 21 22:36:25 CET 2015

On Wed, Jan 21, 2015 at 11:27 AM, Joao S. O. Bueno
<jsbueno at python.org.br> wrote:
> 1)  Implement a Number class that behaves as a float number, and does
> the fuzzy comparisons automatically.
> Justificative: in a whole lot of code, having a "casted"
> FuzzyFloat(mynumber) to be able to be compared to others with "==" and "<="
> would be much more readable than the Javaesque
> " if is_close(my_number, other) or my_number < other: "
> (against:
>  "if FuzzyFloat(my_number) <= other :"
> , or simply

I'm sure this has come up somewhere, but I have to say that I've never
in my life seen a situation where an approximate <= was the correct
solution to a problem. I've seen lots of exact <= (which you just
assume is interchangeable with <) and approximate ==, but never
approximate <=.


Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh

More information about the Python-ideas mailing list