I noticed a difference with round() at 15 decimal places, and I need to know why this is so.
5 次查看(过去 30 天)
显示 更早的评论
Yesterday, I noticed that
round(2.4999999999999999) %15 decimal places
ans =
3
But
round(2.499999999999999) %16 decimal places
ans =
2
This can be for any number, not just 2. Does anybody know what causes this?
1 个评论
采纳的回答
Mara Gati
2016-4-16
1 个评论
John D'Errico
2016-4-16
It is not 15 decimal digits that matters, since doubles are not stored in decimal form. A double in MATLAB is actually stored in binary. So 52 binary bits represents something a little more accurate than 15 decimal digits.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!