First time here? Check out the FAQ!
x

eq: not working

+1 vote
111 views
Greetings,

using : (!Vari roundTo: 0.1) eq: 0.5

I am not getting a result . It is always 0 even if !Vari becomes 0.5.

On the other hand, if I do this :

(!Vari roundTo: 0.1) eq: (!Vari2 roundTo: 0.1)

Then it works as it should

I am using Sound To Global Controler for these tests with the latest kyma version

best

Rastko
asked Mar 18 in Capytalk & Smalltalk by rastko-lazic (Practitioner) (320 points)
If you put eq: to some numbers such as 0.4, 0.8, 0.2 then it works too.

1 Answer

0 votes

This has to do with the fact that 0.1 doesn't have a finite representation in binary (For more details, see R. Regan's article: "Why 0.1 Does not Exist in Floating-Point ).

One solution in this case might be to use: (!Vari * 10) rounded eq: 5

 

 

answered May 7 by ssc (Savant) (89,900 points)
Thank you for the explanation and a solution .
...