Mis match in comparing the values

1 回表示 (過去 30 日間)
Raghavendra
Raghavendra 2012 年 9 月 11 日
Hello all,
a=1.3;
b=0.1+0.2+0.2+0.3+0.3+0.1+0.1;
If I perform a==b, then I am getting the result 0(means both are not equal).
But actually they are equal(Both has a value of 1.3)
What's going wrong here? Plz let me know....
Best Regards,
Raghavendra
  1 件のコメント
Jan
Jan 2012 年 9 月 11 日
Dear Raghavendra, welcome to the world of floating point numbers on computers. Equivalent questions have been discussed such frequently, that this topic have been included in the FAQ. Follow Oleg's link and study the other problems also, because they occur frequently, as the name says already.
To all readers: If you have not done this already, read the FAQ also.

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

採用された回答

Oleg Komarov
Oleg Komarov 2012 年 9 月 11 日
  1 件のコメント
Raghavendra
Raghavendra 2012 年 9 月 14 日
Thank you for your answer:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by