I'm learning Julia currently and have encountered a strange result (which I don't think to be Julia's specific behavior!), and I'm eager to find out why. In Julia, one can check the equality between two values (like Integer, Float, etc.) using ==
or isequal()
. For example, you can check the equality between 4
and the expression 2+2
like this:
julia> isequal(4, 2+2)
true
But when I tried these two following statements, I got an unexpected result:
julia> isequal(0.6, 0.5 + 0.1)
true
julia> isequal(0.6, 0.4 + 0.2)
false
I'm confused why this differs. Any help would be appreciated.
Also is there function in Julia that can perform an inexact equality comparison?