[Python-ideas] [Python Ideas] Python Float Update

u8y7541 The Awesome Person surya.subbarao1 at gmail.com
Thu Jun 4 00:46:00 CEST 2015


On Wed, Jun 3, 2015 at 3:35 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
> On Jun 3, 2015, at 15:17, u8y7541 The Awesome Person <surya.subbarao1 at gmail.com> wrote:
>
>>> I?m going to show a few examples of how Decimals violate the fundamental
>>> laws of mathematics just as floats do.
>>
>> Decimal is also uses sign and mantissa, except it's Base 10. I think
>> Decimal should use numerators and denominators, because they are more
>> accurate.
>
> So sqrt(2) should be represented as an exact fraction? Do you have infinite RAM?
>

You can't represent sqrt(2) exactly with sign and mantissa either.
When Decimal detects a non-repeating decimal, it should round it, and
assign it a numerator and denominator something like 14142135623730951
/ 10000000000000000 simplified. That's better than sign and mantissa
errors.

Or an alternative could be a hybrid of sign and mantissa and fraction
representation... I don't think that's a good idea though.


-- 
-Surya Subbarao


More information about the Python-ideas mailing list