[Python-ideas] Python-ideas Digest, Vol 103, Issue 29

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


>
> Stephen J. Turnbull writes:
>
>> Nick Coghlan writes:
>>
>>> the main concern I have with [a FloatLiteral that carries the
>>> original repr around] is that we'd be trading the status quo for a
>>> situation where "Decimal(1.3)" and "Decimal(13/10)" gave different
>>> answers.
>>
>> Yeah, and that kills the deal for me.  Either Decimal is the default
>> representation for non-integers, or this is a no-go.  And that isn't
>> going to happen.
>
> What if also 13/10 yielded a fraction?

Yeah, either Decimal becomes default or 13/10 is a fraction. If
Decimal becomes default, we could have Decimal(13 / 10) = Decimal(13)
/ Decimal(10). We would have "expected" results.

Also,

>Fractions and Decimals can't be mixed or interconverted directly.

If Decimals are default, Fractions can have a .divide() method which
returns Decimal(Numerator) / Decimal(Denominator), which is used when
Fractions and Decimals are mixed.

-Surya Subbarao


More information about the Python-ideas mailing list