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

Gareth McCaughan Gareth.McCaughan at pobox.com
Fri Jul 27 18:21:22 EDT 2001


Guido van Rossum wrote:

[Bengt Richter:]
> > ISTM floor couldn't make an exact number out of an inexact one
> > unless the inexactness was known to be constrained to the halfopen
> > interval above the floor.
> 
> Good point.
...
> > Here's another one. What if you were simulating white noise within
> > an interval, and you wanted to check on it by counting instances
> > generated that fell in sub-intervals. Scaling the sub-intervals to
> > width 1.0 and using floor would be a natural way of getting an index
> > to bins for counting. So one way or another, there has to be a way
> > to make the floored values exact for the purpose of indexing.
> 
> So use int(floor(x)).
[etc]

For what it's worth, Common Lisp (which I think generally
gets these issues very right) has FLOOR return an integer,
not a float of appropriate type. (It does return a second
value, which is the remainder; as I've said before, CL does
multiple return values very differently from Python.)

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
.sig under construc



More information about the Python-list mailing list