Integer division (was: Case-sensitivity... (was: Damnation!))
Moshe Zadka
moshez at math.huji.ac.il
Sun May 21 14:56:23 EDT 2000
On 21 May 2000, Bernhard Herzog wrote:
> If i/j does not do integer division, the only real solution seems to be
> what Moshe Zadka proposed: introduction of a rational type with (long)
> int numerator/denominator pairs.
>
> I'm not sure I'd like that. It sounds like a serious performance hit.
Well, premature optimization is the root of all evil: much better to go
for correctness, and let the user optimize memory with
float(i/j) --> get a floating point approx.
quotient(i, j) == int(i/j) --> get the integral part of i/j (negative
number issues are undecided)
> You could easily end up carrying around a lot of precision that's not
> needed in many applications.
And if that becomes a problem, just optimize it away.
> This could be alleviated by introducing a special integer division
> operator.
Or a builtin function -- I doubt there is so much need for one it deserves
its own little SHIFT+number character.
rationally y'rs, Z.
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list
mailing list