[Python-ideas] Python Numbers as Human Concept Decimal System

Mark H. Harris harrismh777 at gmail.com
Fri Mar 7 07:39:35 CET 2014



On Friday, March 7, 2014 12:11:21 AM UTC-6, Steven D'Aprano wrote:
 

> For the first few releases of Decimal, it prohibited direct conversion 
> of floats specifically to avoid that issue: 
>
> # Python 2.5 
> py> decimal.Decimal(2.01) 
> Traceback (most recent call last): 
>   File "<stdin>", line 1, in <module> 
>   File "/usr/local/lib/python2.5/decimal.py", line 648, in __new__ 
>     "First convert the float to a string") 
> TypeError: Cannot convert float to Decimal.  First convert the float to a 
> string 
>
>
> But that turned out to be more of a nuisance than what it was 
> trying to protect from, so starting in Python 2.7 Decimal now 
> supports direct and exact conversion from float. 


hey Steven,   whoa...!   that is useful, and very interesting news. That 
almost makes me want to cry.... 
Wait a minute, I'm going to check it out, ...  son of a gun, you're right. 
My Py2.6.1 does not
allow me to enter this   sqrt( .789 ).   What-da-ya-know........ Here is 
the output:

>>> from pdeclib import *
>>> sqrt(.789)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pdeclib.py", line 243, in sqrt
    sqr=Decimal(x).sqrt()
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/decimal.py", 
line 652, in __new__
    "First convert the float to a string")
TypeError: Cannot convert float to Decimal.  First convert the float to a 
string
>>> 
 
So, "ignorant boy" finds out that the community has come to court with 
unclean hands !  

Everyone (even the core devs) know that this little problem sucks, and 
they've tried to
fix it in different ways, and yet when I bring it up its like (hypocrisy) 
I'm the one with the
problem--- when in fact all along everyone knows that this little IED was 
going to go off and
make a mess.   ~nice.

<sigh>   Steven,  I honor you and thank you for being honest and coming 
clean on this. 

Geeze... I'm going to bed.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140306/3e251deb/attachment.html>


More information about the Python-ideas mailing list