A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-June/045463.html below:

[Python-Dev] Comparing heterogeneous types

[Python-Dev] Comparing heterogeneous typesArmin Rigo arigo at tunes.org
Thu Jun 17 14:38:06 EDT 2004
Hello Michael,

On Wed, Jun 02, 2004 at 05:18:44PM -0400, Chermside, Michael wrote:
> the long could be less than MAX_FLOAT,
> but still not be precisely representably as a float. In a case
> like this, we really need to convert both to longs and compare
> (or something equivalent) and your code fails to do this.

Is it really what we want?  It seems to me that the precision of a float gives
roughly the magnitude of "uncertainty" of the value that it represents.  If a
float is large enough, then the same float can represent several long integer
values.  It should then probably be considered equal to any of these integers,
instead of just equal to the one arbitrarily returned by casting it to long.

>>> L = 2**60
>>> float(L)
1.152921504606847e+18
>>> float(L) == float(L+1)
True

In this situation I would expect this float(L) value to be equal to both L and
L+1.  (But equality between floats is messy anyway.)


A bientot,

Armin.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4