Video tutorial: Tolerances in comparisons
if (answer == 1)
Do something
end
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 abs(answer - 1) < 1e-14
Do something
end
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.