[Python-Dev] Mixing float and Decimal -- thread reboot

Paul Moore p.f.moore at gmail.com
Mon Mar 22 21:45:05 CET 2010


On 22 March 2010 19:32, Mark Dickinson <dickinsm at gmail.com> wrote:
> I think getting this to work would involve a lot of extra code and
> significant 'cleverness'.  I'd prefer the simple-to-implement and
> simple-to-explain option of rounding the Fraction before performing
> the operation, even if this means that the whole operation involves
> two rounding operations.  It's not so different from what currently
> happens for Fraction+float, or even int+float.

My instinct throughout this discussion has been that

    a_decimal + a_fraction

is in effect

    a_decimal + a_fraction.numerator / a_fraction.denominator

and as the numerator and denomination can be converted into exact
decimals, my instincts "expect" a double rounding. Anything else
effectively means implementing partial cases of  (a+b/c) treated as a
ternary operation.

So I guess I'm +1 on Mark's suggestion.
Paul.


More information about the Python-Dev mailing list