<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Mar 7, 2014, at 11:01, "Mark H. Harris" <<a href="mailto:harrismh777@gmail.com">harrismh777@gmail.com</a>> wrote:</div><blockquote type="cite"><div><div dir="ltr"><div><div><span style="font-size: 13px;"><br></span></div><div><span style="font-size: 13px;">Here is the main post for today, from me, having slept on this and putting some things</span></div><div><span style="font-size: 13px;">back into historical timeframe. Sometime before Py2.7.x it was not possible to promote</span></div><div><span style="font-size: 13px;">a binary float to a decimal float; the system threw an exception (convert to string).</span></div><div><span style="font-size: 13px;"><br></span></div><div><span style="font-size: 13px;">First, that was the correct way to handle this issue from the inception of decimal.Decimal. Throw</span></div><div><span style="font-size: 13px;">an exception and let everyone know that there is a problem; then let the user figure out how to</span></div><div><span style="font-size: 13px;">solve it.</span></div></div></div></div></blockquote><div><br></div><div>The decision was discussed at the time, and all the pros and cons were hashed out. If you're not willing to read that discussion, your opinion that the change was a mistake is worth exactly as much as that of any individual user who asked for the change.</div><br><blockquote type="cite"><div><div dir="ltr"><div><div><span style="font-size: 13px;">It is not possible to correctly promote a binary float to a decimal float. The decision (in Py2.7?)</span></div><div><span style="font-size: 13px;">was to NOT throw an exception and to copy the binary float "exactly" into the decimal float.</span></div></div></div></div></blockquote><div><br></div><div>There is no such thing as copying a binary float exactly into a decimal float. Decimal float values are not a superset of binary float values; in either direction, you have to round. Which is what Python 2.7+ does.</div><div><br></div><blockquote type="cite"><div dir="ltr"><div><span style="font-size: 13px; ">Steven, I am going to try to go a little further without AI speak... What needs to happen is that </span></div></div></blockquote><blockquote type="cite"><div dir="ltr"><div><span style="font-size: 13px;">binary floats need to be "correctly" promoted to decimal floats as appropriate. This must not happen</span></div><div><span style="font-size: 13px;">by simple copying (that does not work). There needs to be some policy in place that will correctly</span></div><div><span style="font-size: 13px;">"set" the decimal float value based on intelligence, not just simple copying. ( It may not be possible, or</span></div><div><span style="font-size: 13px;">it may require some funky copy b float-->reduce context round-->set decimal . I'm still thinking about it.</span></div></div></blockquote><div><br></div>Python is _already_ doing exactly what you're asking for. Each binary float is rounded to the closest possible decimal float.<div><br></div><div>And it's hard to imagine what else it _could_ be doing. There is no closer decimal than the closest decimal, so any "smarter" algorithm would either do the exact same thing, or be worse.</div><div><br></div><div>It's true that this "doesn't work" to solve your problem, but that's only because you're trying to solve an impossible problem. Once you've rounded a number inexactly (whether to binary or decimal), you can't get the lost data back.</div><div><div><br><blockquote type="cite"><div dir="ltr"><div>To make decimal the default, and to handle all numbers correctly giving the SciPy community the</div><div>ability to use binary floats easily too (without breaking codes) will require a complete rewrite of</div><div>numbers.Number and maybe some other things. </div></div></blockquote><div><br></div><div>Why do you keep saying that even after it's been repeatedly explained to you that it wouldn't? Number and its subclasses do not care about the representation of the number. Guido explained to you exactly what would and wouldn't need to be changed, and the abstract base classes do not enter into it.</div></div></div><div><br></div></body></html>