MATLAB: Why doenst this work as expected

floating pointprecision

format long;
tmp = 0:1/200:1800-1/200;
tmp(10083)
the third line returns something like   50.410000000000004
why the trailing …004? its a double too, so shouldn't it work?

Best Answer

Because even double precision is not exact for decimal numbers. Here is one of many possible starting points to read more.