<div dir="ltr">On Sat, Mar 8, 2014 at 9:43 AM, Mark Dickinson <span dir="ltr"><<a href="mailto:dickinsm@gmail.com" target="_blank">dickinsm@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br></div><div class="gmail_quote">
I see three sane options for float to Decimal conversion:<div><br></div><div>1. Raise an exception.</div><div>2. Round to the nearest Decimal value using the current context for that round operation.</div><div>3. Do what we're currently doing, and do an exact conversion.</div>
</div></div></div></blockquote><div><br></div><div>Proposals for change should also take into consideration that Decimal already does *exact* conversions for integers (and I believe has done since it first existed). It would be quite surprising for `Decimal(2**1000)` and `Decimal(2.0**1000)` to be different numbers. If we change the float behaviour, we might also want to change conversion from int to round to the nearest Decimal using the current context. Again, that's closer to what IEEE 754 specifies for the "convertFromInt" operation.<br>
</div><div><br></div><div>On the other hand, we probably shouldn't lend *too* much weight to IEEE 754, especially when talking about choice of precision. IEEE 754 isn't a perfect fit for Decimal: the IEEE standard is mostly concerned with fixed width decimal formats, which is subtly different from Mike Cowlishaw's approach of "extensible precision" where the precision is not so closely tied to the format. Python's decimal module is based on Cowlishaw's standard, not on IEEE 754.</div>
<div><br></div><div>Mark</div><div><br></div><div><br></div></div></div></div>