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

Mark H. Harris harrismh777 at gmail.com
Fri Mar 7 01:17:55 CET 2014



On Thursday, March 6, 2014 4:41:08 PM UTC-6, Chris Angelico wrote:

What does your proposed hierarchy offer that numbers.Number doesn't? 
>
>  
I just had one more thought along this line;  consider this:

>>> from pdeclib import *
>>> 
>>> s1=sqrt(2.01)
>>> s1
Decimal('1.41774468787578244511883132198668766452744')
>>> s2=sqrt(d(2.01))
>>> s2
Decimal('1.41774468787578252029556185427085779261123')
>>> 
>>> s1**2
Decimal('2.00999999999999978683717927196994423866272')
>>> s2**2
Decimal('2.01000000000000000000000000000000000000000')
>>> 
>>> 

Which one is right,   s1 or s2 ?

Well, clearly s1 is wrong.  And yet, s1 was coded by giving the system a 
normal
human number, at a human level, and very innocently s1 is really badly 
broken
but not immediately noticed until we try to square it...  

s2 on the other hand is correct, but we had to go through some hoops
to make sure that the system received the correct type.  The system should 
be able to make this determination without the user having to determine 
types.

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


More information about the Python-ideas mailing list