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 帐户或创建一个新帐户。