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?

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 16 de Feb. de 2012

2 votos

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

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Jas
el 16 de Feb. de 2012

Editada:

el 14 de Oct. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by