HELP: restore my faith in Python

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Mar 6 04:50:35 EST 2000


"Tim Peters" <tim_one at email.msn.com> writes:

> is more useful?  How about
> 
>     int(0.999999999999999999993427) == 1
>     int(0.99999999999999999993427) == 1
>     int(0.9999999999999999993427) == 1
>     int(0.999999999999999993427) == 1
> 
> and so on?  So long as you draw the line *somewhere*, you haven't solved
> anything, you've merely moved the surprises from where they're predictable
> across *all* IEEE-754 platforms to something unique to Python.
> 
> The problems with floating-point are deep and can't be patched over.  "Quick
> hacks" always backfire.  If somebody wants to indulge in a notion of "safe
> epsilon", there's nothing to stop them from writing that explicitly.

APL has a "comparison tolerance", implemented as a global (but
localizable) variable that can be changed by the user, and which
specifies the maximum relative error that is considered zero for the
purpose of comparisons. It's a handy feature for quick calculator-type
calculations, but it can get in the way when implementing more complex
algorithms.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------



More information about the Python-list mailing list