How about adding rational fraction to Python?

Paul Rubin http
Sat Feb 16 17:09:53 EST 2008


Carl Banks <pavlovevidence at gmail.com> writes:
> Rationals are pretty useless for almost any extended calculations,
> since the denominator tends to grow in size till it's practically
> unusbale, which means you have to periodically do non-exact reductions
> to keep things running, and if you do that you might as well be using
> floating point.

This only happens if you're chaining many divisions by non-constants,
which in the typical business calculation does not happen.  Those
calculations divide by 10 a lot, and sometimes by 12 or 365, but they
rarely divide a calculated quantity by another calculated quantity,
especially to more than one level.  I.e. they might compute the ratio
of widgets sold to widgets repaired, but they wouldn't then divide
that ratio by some other weird number.

I did in fact implement rational arithmetic in a business app a long
time ago, because management wanted it.  I had the same concerns that
you express, but they just weren't a problem in practice.



More information about the Python-list mailing list