[squeak-dev] Decimals as fractions
K K Subbu
kksubbu.ml at gmail.com
Mon Apr 8 17:22:45 UTC 2019
On 08/04/19 2:52 PM, K K Subbu wrote:
>
>> We currently have ScaledDecimal with 3.41s or 3.42s2 syntax.
>> The problem with ScaledDecimal is that their printing is ambiguous:
>> two different ScaledDecimal may print the same.
>>
>> {1.0s2 / 3.0s2. 0.33s2} collect: #printString.
>> {1.0s2 / 3.0s2. 0.33s2} collect: #reciprocal.
>
> Is Squeak 5.3alpha/64b/Linux, I get
>
> {1.0s2 / 3.0s2. 0.33s2} collect: #reciprocal {3.00s2 . 3.03s2}.
>
> But I get your point. For decimal numbers, using both denominator and
> scale is an overkill. Printing can be handled by the existing
> printFractionAs... . Reciprocal of a decimal number could become
> imprecise operation, so we could fall back to Float when necessary.
>
> With decimal numbers, we could print
> 0.25 reciprocal = 4
> instead of the current
> 0.25 reciprocal = 4.166666666666667
PBKAC! mea culpa. I meant to say I expected 4 instead of 4.0.
ScaledDecimal looks promising but I don't know why it doesn't reduce
like Fraction:
self assert: (0.25s reciprocal class) classAndValueEquals: 4
Regards .. Subbu
More information about the Squeak-dev
mailing list
|