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

Ron Adam ron3200 at gmail.com
Sun Mar 9 16:19:00 CET 2014


On 03/09/2014 09:59 AM, Antoine Pitrou wrote:
> Therefore, decimal.Decimal(1.1) is the exact decimal value of the
> binary floating-point number*best approaching*  the decimal literal '1.1':
>
>    >>> decimal.Decimal(1.1)
>    Decimal('1.100000000000000088817841970012523233890533447265625')
>    >>> decimal.Decimal('1.100000000000000088817841970012523233890533447265625') == 1.1
>    True
>
> Indeed, the difference is less than a binary floating-point mantissa's
> resolution:

Yes, I realized that using the number closest to zero, is an implicit 
rounding down, after I posted.

The increases resolution accounted for the slightly less results in the 
examples.  But because it was using the value closest to the decimal 
representation (the quoted value) instead of the exact float value.  The 
higher resolution might be slightly higher or lower in that case and have 
extra, or even possibly (but more rarely) fewer digits. (is that right?)

The decimal is more accurate in that manner.  But more picky about quality 
too.  Looks like there is a way to set that in the context.. So that (value 
+- some error amount) is used in the equality tests.  Anyway need to go... 
  Check back later this evening.

Cheers,
    Ron




More information about the Python-ideas mailing list