This may be a very basic question, but it is driving me nuts. I've created a minimal example that demonstrates the issue.
I'm creating a list of numbers (to use as Ticks in a plot) as follows:
Table[y, {y, -0.50, 0.50, 0.10}]
That works exactly as I would expect, passing through exactly zero, giving the output below:
In[291]:= Table[y, {y, -0.50, 0.50, 0.10}]
Out[291]= {-0.5, -0.4, -0.3, -0.2, -0.1, 0., 0.1, 0.2, 0.3, 0.4, 0.5}
However, this does not work as expected:
Table[y, {y, -0.60, 0.60, 0.10}]
That one does not pass through zero, and I don't understand why. Here is the output:
In[292]:= Table[y, {y, -0.60, 0.60, 0.10}]
Out[292]= {-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 1.11022*10^-16, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6}
I know that I can fix that by using Round[] as follows:
Table[N[Round[y, 10^-4]], {y, -0.60, 0.60, 0.10}]
and here is the output (note that it seems that N[] is required to avoid fractions):
In[295]:= Table[N[Round[y, 10^-4]], {y, -0.60, 0.60, 0.10}]
Out[295]= {-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6}
So, my question is why, when you go from -0.5 to 0.5 in steps of 0.10 does it pass through 0, but when you go from -0.6 to 0.6 in steps of 0.10 it does not? Seems to me that I should get the output shown in the last box without having to use Round[].
Attachments: