When I use 'eq' function or '==' I get strange results.
eq((0.6-0.2-0.2),0.2)
ans =
0
Please tell me why Matlab does not return true? What is not correct?

 採用された回答

Oleg Komarov
Oleg Komarov 2012 年 2 月 16 日

2 投票

In brief, note that .6 -.2 -.2 not equal to .2:
sprintf('%.17f',0.6-0.2-0.2)
ans =
0.19999999999999996

1 件のコメント

Jan
Jan 2012 年 2 月 16 日
An evergreen!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

Jas
2012 年 2 月 16 日

編集済み:

2013 年 10 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by