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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup 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