Rounding using 'fix'... possibly a bug?
显示 更早的评论
Could someone tell me if this is a bug, or is there some logical reason 'fix' would round:
.3/.1 = 2
whereas
.4/.1 = 4
K>> fix(.3/.1)
ans =
2
K>> fix(.4/.1)
ans =
4
K>> fix(.7/.1)
ans =
6
K>> fix(.5/.1)
ans =
5
1 个评论
Jan
2013-10-14
It is such surprising that the well known floating point effects appear for beginners usually for the value 0.3 . Usually it is:
find((0:0.1:1) == 0.3) % replies [] !!!
采纳的回答
更多回答(1 个)
Image Analyst
2013-10-14
1 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Physics 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!