Function 'eq'

4 views (last 30 days)
Jas
Jas on 16 Feb 2012
Edited: Cedric on 14 Oct 2013
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?

Accepted Answer

Oleg Komarov
Oleg Komarov on 16 Feb 2012
In brief, note that .6 -.2 -.2 not equal to .2:
sprintf('%.17f',0.6-0.2-0.2)
ans =
0.19999999999999996
  1 Comment
Jan
Jan on 16 Feb 2012
An evergreen!

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!