Function 'eq'
4 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Oleg Komarov
on 16 Feb 2012
Please read this faq: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
In brief, note that .6 -.2 -.2 not equal to .2:
sprintf('%.17f',0.6-0.2-0.2)
ans =
0.19999999999999996
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!