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

Raymond Hettinger raymond.hettinger at gmail.com
Mon Mar 22 20:03:55 CET 2010


On Mar 22, 2010, at 11:54 AM, Guido van Rossum wrote:
> 
> So now we have a second-order decision to make -- whether
> Decimal+float should convert the float to Decimal using the current
> context's precision, or do it exactly. I think we should just follow
> Decimal.from_float() here, which AFAIK does the conversion exactly --
> the operation will already round properly if needed, and I don't think
> it is a good idea to round twice in the same operation. (Even though
> this is what long+float does -- but the situation is different there
> since float has no variable precision.)

I concur.  That is consistent with the basic design of the decimal
module which treats inputs as exact and only applies rounding
to the results of operations.

FWIW, Mark and I have both been bitten severely by doubling
rounding in the world of binary floats.  Avoiding double rounding
is a darned good idea.


Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100322/a7d01aaa/attachment.html>


More information about the Python-Dev mailing list