The result of 0.3+0.15==0.45 is true or false?
5 views (last 30 days)
Show older comments
Hi, I have a problem. I ran this expression "0.3+0.15==0.45" in Matlab the result is "0", but I ran the same expression in Mathematica, the result is "True". Why is that? AND if a,b are both variables for floating-point numbers, is it acceptable if I use "a==b" as the condition in the "if function"? Could anybody help me out? Thanks a lot!
0 Comments
Accepted Answer
Daniel Shub
on 13 Dec 2011
You might want to start with the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
3 Comments
Jan
on 14 Dec 2011
@Jiasen: It is a good idea to read the complete FAQ - why not takine advantage from the problems of others...
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!