It evaluates to false in VW too. I guess it is a matter of internal representation, since ScaledDecimals/FixedPoints are a Fraction after all. What is weird, and I'd say wrong (at least from the UX perspective) is that in Pharo (and Dolphin): ((91 - (2 * 35.9) - (0 / 2) * (113/121)) roundTo: 0.1) -> 17.900000000000002 While in VW and VAST they round the float properly: ((91 - (2 * 35.9) - (0 / 2) * (113/121)) roundTo: 0.1) -> 17.9 Regards! Esteban A. Maringolo On Tue, Sep 1, 2020 at 1:24 AM jtuchel@objektfabrik.de <jtuchel@objektfabrik.de> wrote:
Interesting. Your expression evaluates to true in VA Smalltalk.
Am 01.09.20 um 06:17 schrieb Esteban Maringolo:
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 <emaringolo@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
-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:jtuchel@objektfabrik.de Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1