From: "Dennis E. Hamilton" <dennis.hamilton@acm.org> To: <edu-sig@python.org> Subject: RE: [Edu-sig] Re: rationals Date: Fri, 11 Oct 2002 18:25:24 -0700

The biggest difference is that some floating-point calculations that will converge (disappear at 0 or converge on a fixed value) will not terminate in rational computation.

Since this sort of thing is not a very good way to use floats either, it should provoke more-appropriate numerical techniques.

Right--I thought that the more accepted technique was to (if we're going for zero) pick an epsilon, and then exit when abs(arg)<epsilon (and if we converge to something else, perhaps to pick an epsilon, and quit when the last ten arguments were within epsilon of each other). re: int/int --> float Wha? But the definition of rational is the set of numbers that can be represented as int/int! I understand the speediness argument, but please, let us not go float unless we coerce there! I thought the whole point of the rational thread was for "1/3" to simplify to something meaningful. Would it work (just throwing this out, having no real idea of how rats are implemented elsewhere) to set each of the numerator and the denominator to be a dict of the prime factorization thereof (assuming we are working with <100 digit numerals)? Or we could say that "int/int --> float, int//int --> int, and int///int --> rational". But this feels like a dangerous road. It'll be neat to have a set of numbers, though, where division is cheaper than addition.