Under Matlab 2014b, when making:
round((0.1:0.2:1)/0.2)
I obtain:
1 2 3 3 5
Instead of
1 2 3 4 5
Is there a way to fix such weird computation? Why this happens? Why so weird? This repeats for other values, not only n=0.2
.
EDIT: I checked the duplicate but, do the scenario changes when using ceil
so the floating point threshold is not in the half integer (0.5, 1.5, 2.5) but in the integer (1.0, 2.0, 3.0)? What if i use some other representation, like single
? Or any other more predictable?