my question is quite simple, i want to construct a nuumberline for a homework and came up with the following code:
\begin{tikzpicture}
\draw(0,0)--(16,0);
\foreach \x/\y in {0/0,1.6/0.2,...,16.2/2.1}
\draw(\x,0.2)--(\x,-0.2) node [below] {\y};
\end{tikzpicture}
This produces the following output:

The first two labeled values are okay, but for some reasons \y gets the values of \x (which is definetly not wanted). Also I want to get rid of the floating point unprecission.
How can I fix this?


\xcan scaled easily with TikZ by many means, i.e.x=1.6cm.) And evaluate\yvia, say,\pgfmathprint{\x/8}. If you're still getting bad digits, there's\pgfmathprintnumber, [tag:siunitx] or simply\fpeval{\x/8}. The most recent Q&A in the [tag:floating-point] tag you used is a good starting point for different loop mechanism (no example, though, unfortunately) and for related Q&A. – Qrrbrbirlbel Dec 01 '23 at 21:23\fpevalwas exactly what I was looking for! – Daerker Dec 01 '23 at 21:37