proposed language change to int/int==float (was: PEP0238 lament)
Terry Reedy
tjreedy at home.com
Tue Jul 24 15:18:06 EDT 2001
> > In my model there are four builtin numeric types: int, rational,
> > float, and complex. The intent is that floats approximate real
numbers.
Note: *approximate*
> Unfortunately, this isn't really all that consistent. Consider the
> calculation
>
> sqrt(2)**2 == 2
>
> By pretty much the same arguments as have been used elsewhere in
this
> discussion, I'm sure that you would expect this to evaluate to true.
No, approximate is not equal. For float 'equality', one should always
test near equality.
abs(sqrt(2)**2 - 2) <= delta
and yes, choosing delta is sometimes an art.
More information about the Python-list
mailing list