The result of 0.3+0.15==0.45 is true or false?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Daniel Shub
2011-12-13
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 个评论
Jan
2011-12-14
@Jiasen: It is a good idea to read the complete FAQ - why not takine advantage from the problems of others...
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!