proposed language change to int/int==float (was: PEP0238 lament)

Skip Montanaro skip at pobox.com
Thu Jul 26 02:50:30 EDT 2001


    Paul> The most obvious problem is that it implies that every rational
    Paul> can be represented as a float -- this is *severe* brokenness you
    Paul> don't need.  [I think it also implies that floats with integral
    Paul> values (1.0, etc.)  should turn into integers.]

You can't do that.  Suppose that value you think is 1.0 really got truncated
during a previous calculation because your fp hardware doesn't have enough
bits and lost it?  If you convert that to the integer 1 you're screwed
because you are pretending your inexact approximation of the real value is
the real value.  You're better off admitting you have an inexact value and
planning accordingly.  The only time the VM can convert from inexact to
exact (e.g., float->rational, float->int) is when the programmer says you
can with a cast.

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list