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?

 Akzeptierte Antwort

Oleg Komarov
Oleg Komarov am 16 Feb. 2012

2 Stimmen

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

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

Jas
am 16 Feb. 2012

Bearbeitet:

am 14 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by