Message210495
Oscar Benjamin <report@bugs.python.org> 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
> decimalsum.py 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:37 | skrah | set | recipients:
+ skrah, steven.daprano, oscarbenjamin, wolma |
2014-02-07 17:00:37 | skrah | link | issue20499 messages |
2014-02-07 17:00:37 | skrah | create | |
|