MATLAB: I noticed a difference with round() at 15 decimal places, and I need to know why this is so.

decimal placesround

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?

Best Answer

It's OK, I found the answer. Floating point doubles are precise to 15dp only.