Matlab gives wrong answer

前端 未结 3 494
小蘑菇
小蘑菇 2020-12-07 02:11

If the following code is executed MATLAB makes a mistake. Can someone verify this?

floor([0.1:0.1:2]/0.01)

So what is the 129 doing here??<

3条回答
  •  忘掉有多难
    2020-12-07 02:42

    It is probably doing a floating point calculation resulting in an inexact value of 129.99999999999999... something instead of 130. and then you floor it to 129.

提交回复
热议问题