number comparison problem

Lance lbrannma at cablespeed.com
Wed Oct 16 05:56:44 CEST 2002


Chris,

I suspect they are the results of a floating point calculation and not as
described. Hence, you need to set a fuzzy comparison tolerance. I don't know
how to do it in Python.

Lance

"Chris Fonnesbeck" <spam at fisher.forestry.uga.edu> wrote in message
news:c3835e5f.0210151910.28fff95b at posting.google.com...
> I am using python to code an optimization function that requires
> numbers to be compared to one another, as is common in many
> algorithms.  However, the comparison operators (<,>,<=,>=,==) seem not
> to be working properly.  Regard the following:
>
> >>> print fb,fc
>
> 0.132945911028 0.132945911028
>
> >>> print fb>fc
>
> 1
>
>
> These numbers look the same to me; what do I have to do to be able to
> test numbers accurately in python?
>
> TIA,
> cjf





More information about the Python-list mailing list