Why does 2.0 - 1.8 not result in 0.2?
pp! 2.0 - 1.8
2.0 - 1.8 # => 0.19999999999999996
Why does 2.0 - 1.8 not result in 0.2?
pp! 2.0 - 1.8
2.0 - 1.8 # => 0.19999999999999996
Wikipedia has info on it: https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems
TL;DR: Floats are less precise than one would expect. It’s not specific to Crystal.
Thanks
Also, Ruby prints it right, but Ruby uses another algorithm to print floats. You could open an issue/bug if you’d like to.
Oh, I spoke too soon, Ruby also prints it like Crystal