rounding to specific values We have a set $M = M(x_0,n,r)\subset \mathbb{R}, r>0, n \in \mathbb{N}$ which has the following properties:
$M$ contains $n$ different values, $\lbrace x_0 - r, x_0+r\rbrace \subset M$ and $|m_i - m_{i+1}| = \dfrac{2r}{n-1} = const$ for every $i \in \lbrace 1,..,n-1  \rbrace$. 
The sets do look like this:
$M(0,5,1) = \lbrace -1, -0.5,0,0.5,1\rbrace$
$M(0,6,1) = \lbrace -1,-0.6,-0.2,0.2,0.6,1 \rbrace$
and so on.. (all values have to be equidistant)
Now I give you a number $\omega \in \mathbb{R}$ and you need to tell me the closest number in $M$ to $\omega$.
For example take $M(0,5,1)$ and $\omega = -0.9$. The number we are looking for is $-1$. 
What I tried to do is the following:
If $M$ has an uneven number of values, the number we are looking for is $\lfloor \dfrac{\omega}{s} + 0.5 \rfloor \cdot s$ where $s$ is the length of a step between two numbers $m_i$ and $m_{i+1}$ given by $s = \dfrac{2r}{n-1}$. It also rounds values like $\omega = 42.2$ to $42$ when working with $M(0,5,1)$ but that's okay. 
Indeed I did not get this to work with $n$ as a even number. I think there is only a small tweak needed for this to work out. 
I tested for example $M(0,6,1)$ with $\omega = 1.1$ which gives $1.2$ but $1.2 \notin M(0,6,1).$ 
 A: The formula you're using is not quite correct, including for an uneven number of values. It works in your example because your formula is implicitly using a base offset value of $0$, so for $x_0 = 0$, then $0$ is one of the values in $M$ if $n$ is odd (e.g., for $n = 5$), but not when $n$ is even (e.g., for $n = 6$, you have $-0.2$ and $0.2$, which is why your incorrect result is off by $0.2$).
To properly find the nearest value, the formula needs to use an appropriate base value as one of the values in $M$, e.g., the smallest value in $M$ of $x_0 - r$. Next, it will "normalize" $\omega$ by subtracting this base value. The closest integral number of steps (either positive or negative) it takes to go from the base value to $\omega$ is determined by dividing the normalized $\omega$ by $s$, adding $0.5$ and then taking the integer value, as your formula does. Finally, the end result is the base value plus the number of steps times the size of each step, i.e., $s$. Putting this all together gives
$$C = b + \left\lfloor \frac{\omega - b}{s} + 0.5 \right\rfloor \cdot s \; \text{ where } \; b = x_0 - r \; \text{ and } \; s = \frac{2r}{n-1} \tag{1}\label{eq1}$$
In general, for any $M(x_0,n,r)$, note the end-points always work correctly. For $\omega = x_0 - r = b$, then $C = b + \left\lfloor \frac{b - b}{s} + 0.5 \right\rfloor \cdot s = b + 0 \cdot s = b = \omega$. For $\omega = x_0 + r$, then $C = b + \left\lfloor \frac{x_0 + r - b}{s} + 0.5 \right\rfloor \cdot s = b + \left\lfloor \frac{2r}{s} + 0.5 \right\rfloor \cdot s$. Now, $\frac{2r}{s} = n - 1$, so $\left\lfloor \frac{2r}{s} + 0.5 \right\rfloor \cdot s = (n-1)\cdot s = 2r$, so $C = b + 2r = x_0 - r + 2r = x_0 + r = \omega$.
For $M(0,5,1)$, with $\omega = 42.2$, you have $b = -1, s = 0.5$ and $C = -1 + \left\lfloor \frac{42.2 - (-1)}{0.5} + 0.5 \right\rfloor \cdot 0.5 = -1 + 86 \cdot 0.5 = 42$. For your other example of $M(0,6,1)$ with $\omega = 1.1$, you have $b = -1, s = 0.4$ and $C = -1 + \left\lfloor \frac{1.1 - (-1)}{0.4} + 0.5 \right\rfloor \cdot 0.4 = -1 + 5\cdot 0.4 = 1$, as expected.
