As a follow up to this, adding a roundTo: before converting into a
ScaledDecimal does not work.

(((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1)
asScaledDecimal: 1) = 17.9s1

So how do you compare two ScaledDecimals that _should_ be the same?

Regards!

Esteban A. Maringolo

On Tue, Sep 1, 2020 at 1:07 AM Esteban Maringolo <emaring...@gmail.com> wrote:
>
> Hi,
>
> I was doing some basic calculations based on a formula, and I wanted
> to convert the result to a scaled decimal in order to avoid having
> these "loose" decimals in 10th position or something similar.
>
> So I did the following:
> 82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1
>
> But When I do this in a test:
> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1
>
> It fails because the comparison returns false.
>
> I guess this is the proper behavior, but I'd expected that the
> conversion from a Float to a scaled decimal would have eliminated the
> extra precision from the formula.
>
> I can do a roundTo: 0.1 before converting, but I'd like to know what
> would be the proper way of dealing with this.
>
> Thanks!
>
> Esteban A. Maringolo

Reply via email to