Thanks all of you. Best regards, Natalia On Jul 11, 2014, at 5:14 PM, Camille Teruel <[email protected]> wrote:
> > On 11 juil. 2014, at 17:02, Natalia Tymchuk <[email protected]> > wrote: > >> But why >> 185/10 = 18.5 -> true? > > Because 18.5 has an exact float representation, while 0.2 hasn't. > > Couldn't we use #asApproximateFraction instead of #asTrueFraction in > Float>>adaptToFraction:andCompare: ? > 0.2 asApproximateFraction ==> (1/5) > 0.2 asTrueFraction ==> (3602879701896397/18014398509481984) > > >> >> On Jul 11, 2014, at 4:40 PM, Norbert Hartl <[email protected]> wrote: >> >>> >>> Am 11.07.2014 um 16:33 schrieb Yuriy Tymchuk <[email protected]>: >>> >>>> >>>> On 11 Jul 2014, at 16:30, Esteban Lorenzano <[email protected]> wrote: >>>> >>>>> On 11 Jul 2014, at 16:22, kilon alios <[email protected]> wrote: >>>>> >>>>>> why not round it before comparing it ? looks like an easy enough problem >>>>>> to fix . I would expect that to be equal. >>>>> >>>>> because it wouldn’t be correct :) >>>> >>>> But then why 4/2 = 2? >>> >>> The same reason why >>> >>> 4/3 = 8/6 >>> >>> :) >>> >>> Norbert >>>> >>>>> >>>>>> >>>>>> >>>>>> On Fri, Jul 11, 2014 at 5:18 PM, Yuriy Tymchuk <[email protected]> >>>>>> wrote: >>>>>> That’s why mathematics and programming are two different things… >>>>>> >>>>>> >>>>>> On 11 Jul 2014, at 16:08, Esteban A. Maringolo <[email protected]> >>>>>> wrote: >>>>>> >>>>>> > Usually comparing against floats is not as deterministic as you would >>>>>> > expect. And in other dialects you use #equals: instead of #= >>>>>> > >>>>>> > But in Pharo there is no #equals: and instead there is a #closeTo:, >>>>>> > but #closeTo: has an arbitrary decimal precision, more than enough for >>>>>> > commong arithmetic. >>>>>> > >>>>>> > Regards! >>>>>> > >>>>>> > Esteban A. Maringolo >>>>>> > >>>>>> > >>>>>> > 2014-07-11 10:59 GMT-03:00 Goubier Thierry <[email protected]>: >>>>>> >> :) >>>>>> >> >>>>>> >> in Smalltalk, the division of two integers is a fraction, not a float. >>>>>> >> >>>>>> >> i.e. 1/5 is 1/5. >>>>>> >> >>>>>> >> Thierry >>>>>> >> >>>>>> >> Le 11/07/2014 15:53, Natalia Tymchuk a écrit : >>>>>> >>> >>>>>> >>> Hello. >>>>>> >>> I found interesting thing: >>>>>> >>> Why it is like this? >>>>>> >>> >>>>>> >>> Best regards, >>>>>> >>> Natalia >>>>>> >>> >>>>>> >> >>>>>> >> -- >>>>>> >> Thierry Goubier >>>>>> >> CEA list >>>>>> >> Laboratoire des Fondations des Systèmes Temps Réel Embarqués >>>>>> >> 91191 Gif sur Yvette Cedex >>>>>> >> France >>>>>> >> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95 >>>>>> >> >>>>>> > >>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >> >
