Video tutorial: Tolerances in comparisons
However, if the calculation was done in double precision, answer might actually be 1.000000001 or something like that. This video discusses a strategy for overcoming this:
if (answer == 1) Do something end
if abs(answer - 1) < 1e-14 Do something end
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.