Hi Natalia, The major problem comes from float memory representation. You can read the beginning of chapter "Fun with Floats" of Deep into Pharo that gives examples of why comparing floats is dangerous. http://rmod.lille.inria.fr/deepIntoPharo/
#Luc 2014-07-11 17:02 GMT+02:00 Natalia Tymchuk <[email protected]>: > But why > 185/10 = 18.5 -> true? > > 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 >> >> >> > >> >> >> > > > > >
