Begin forwarded message:
From: Werner Kassens <wkassens@libello.com> Date: September 18, 2011 5:11:59 PM GMT+02:00 To: Stéphane Ducasse <Stephane.Ducasse@inria.fr> Subject: scaled decimal question
Hi Stephane, occasionally i look at the the Pharo-project mailing list and i saw your question re ScaledDecimals. they are Fractions and you can can look at their internal representation by using asFraction. things like 0.1s2 are fractions built from scratch , hence 0.1s2 asFraction returns 1/10 while (0.1 asScaledDecimal: 2) asFraction returns the same thing as 0.1 asFraction. aFloat asFraction is constructed in such a way that aFloat asFraction asFloat= aFloat for every aFloat. At least with a probability of (100 - epsilon)% with epsilon going to 0. while epsilon is not equal to 0 according to the author of asFraction (see the last comment at the end of Float>>asTrueFraction),obviously nobody has as yet found a counterexample, hence i would forget that. iow (0.1 asScaledDecimal: 2)represents exactly the same number as the float 0.1. since 0.1 + 0.2=0.3 returns false you would of course expect your first example to return false. and you would expect the error in the equality to be similar to the error in 0.1 + 0.2=0.3. although not necessarily equal. if this last statement does not immediately make sense, you might want to think a second or two about the results of these things: ((0.1 asFraction ) + (0.2 asFraction))asFloat = (0.1 +0.2) . ((0.1 asFraction ) + (0.2 asFraction)) = (0.1 +0.2) asFraction .
werner