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

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

u8y7541 The Awesome Person writes:
I gather you haven't read anybody's replies, because, no, you don't get expected results with Decimal: Decimal can still violate all the invariants that binary floats can. Binary has better approximation properties if you care about the *degree* of inexactness rather than the *frequency*[1] of inexactness. Fractions can quickly become very inefficient. Of course you could try approximate fractions with fixed slash or floating slash calculations[2] to get bounds on the complexity of "simple" arithmetic, but then you're back in a world with approximations. Footnotes: [1] In some sense. One important sense is "how often humans would care or even notice", which is likely to be even less frequent than how often inexactness is introduced, for Decimal. But that varies by human. [2] It's in Knuth, Seminumerical Algorithms IIRC.

u8y7541 The Awesome Person writes:
I gather you haven't read anybody's replies, because, no, you don't get expected results with Decimal: Decimal can still violate all the invariants that binary floats can. Binary has better approximation properties if you care about the *degree* of inexactness rather than the *frequency*[1] of inexactness. Fractions can quickly become very inefficient. Of course you could try approximate fractions with fixed slash or floating slash calculations[2] to get bounds on the complexity of "simple" arithmetic, but then you're back in a world with approximations. Footnotes: [1] In some sense. One important sense is "how often humans would care or even notice", which is likely to be even less frequent than how often inexactness is introduced, for Decimal. But that varies by human. [2] It's in Knuth, Seminumerical Algorithms IIRC.
participants (2)
-
Stephen J. Turnbull
-
u8y7541 The Awesome Person