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

David Bolen db3l at fitlinxx.com
Wed Jul 25 16:07:58 EDT 2001


Guido van Rossum <guido at python.org> writes:

> "Bjorn Pettersen" <BPettersen at NAREX.com> writes:
> 
> > I think perhaps an equally interesting example is something like:
> > 
> >   2L**128/2
> > 
> > which currently gives an exact result, but under the proposed new
> > semantics would give an approximation...
> 
> Have you read the PEP?  The PEP only returns a float if the int result
> would yield a remainder.

Does it?  While returning an integral value in the above case,
wouldn't it would in fact be a float data type (barring the addition
of rationals), as per:

    (from PEP238)

    "The type of a/b will be either a float or a rational, depending on
    other PEPs[2, 3]. However, the result will be integral in all case
    the division has no remainder."

And given that, what happens if float can't represent the resulting
precision necessary?

Of course, this is only true later when this is the default, right?
Until then, the "future" implementation is an addition of 0.0 to the
divisor, so the result would definitely be float, and not necessarily
integral.

Unless you meant something other than the data type involved by
"returns a float".

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list