MATLAB Answers

Relational operator == doesn't work properly in some cases!

3 views (last 30 days)
Masood
Masood on 15 Jan 2020
Answered: Star Strider on 15 Jan 2020
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?

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 15 Jan 2020
You are seeing the effects of floating-point approximation error.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by