How about adding rational fraction to Python?

Lie Lie.1296 at gmail.com
Sun Feb 24 12:32:25 EST 2008


On Feb 18, 1:25 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
> On Feb 17, 1:45 pm, Lie <Lie.1... at gmail.com> wrote:
>
> > > Any iteration with repeated divisions and additions can thus run the
> > > denominators up.  This sort of calculation is pretty common (examples:
> > > compound interest, numerical integration).
>
> > Wrong. Addition and subtraction would only grow the denominator up to
> > a certain limit
>
> I said repeated additions and divisions.

Repeated Addition and subtraction can't make fractions grow
infinitely, only multiplication and division could.

> Anyways, addition and subtraction can increase the denominator a lot
> if for some reason you are inputing numbers with many different
> denominators.

Up to a certain limit. After you reached the limit, the fraction would
always be simplifyable.

If the input numerator and denominator have a defined limit, repeated
addition and subtraction to another fraction will also have a defined
limit.



More information about the Python-list mailing list