As the other answers say, Float is inaccurate. Also remember that by default VisualWorks Float has the same precision (about 7 decimal places), if you put your floating-point number with the letter d, for example 5.1d, you get double precision (about 15 decimal places), less inaccurate, but still inaccurate.
Another source of confusion is that two different Float objects can print with the same approximate decimal representation in VisualWorks.
5.1 squared printString -> '26.01'
but
5.1 squared = 26.01 -> false
Note that the last Squeak or Pharo prints enough decimal places to distinguish between different Float (and reinterpret them without changes)
5.1 squared ->26.009999999999998
Alternatively, you can use the so-called FixedPoint (in VisualWorks or ScaledDecimals in other versions) to perform precise operations:
theTestArray :=
Also be careful with this other trap: FixedPoint (ScaledDecimals) only prints as many tens after the fraction point, as was said, but internally it can contain more (infinitely many).
5.1s1 squared printString -> '26.0s1'
but
5.1s1 squared = 26.01s2 -> true
source share