MATLAB: Relational operator == doesn’t work properly in some cases!

codefloating pointMATLABnot a bug

When I run this code:
1.1-1==0.1
I recieve this:
ans =
logical
0
I think it's not rational. Could somebody explain why I'm getting that result?

Best Answer

You are seeing the effects of floating-point approximation error.