This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients oscarbenjamin, skrah, steven.daprano, wolma
Date 2014-02-07.17:00:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
Oscar Benjamin <> wrote:
> If you're going to use decimals though then you can trap inexact and
> keep increasing the precision until it becomes exact.

For sums that is not necessary. Create a context with MAX_EMAX, MIN_EMIN and
MAX_PREC and mpd_add() -- the underlying libmpdec function -- will only use
as many digits as neccessary.

Of course, calculating 1/3 in MAX_PREC would be catastrophic.

> The problem is with rationals that cannot be expressed in a finite number
> of decimal > digits - these need to be handled separately. I've attached
> that shows how to compute an exact sum of any mix of
> int, float and Decimal, but not Fraction.

Yes, I was thinking of a "don't do that" approach. Do people have mixed
Fractions and Decimals in their data?
Date User Action Args
2014-02-07 17:00:37skrahsetrecipients: + skrah, steven.daprano, oscarbenjamin, wolma
2014-02-07 17:00:37skrahlinkissue20499 messages
2014-02-07 17:00:37skrahcreate