# Find an integer that optimize an absolute value

Dears,

Fixed $a\in\mathbb{R}$, consider the problem $\min\{|a+2k|:k\in \mathbb{Z}\}$. It is seems clear that if $k$ is a solution, then $|a+2k|\in[0,1]$, but I don no known how to find such $k$.

Can you help me?

Thanks.

$$|a+2k|\in [0,1]$$ is equivalent to $$|a+2k| \leq 1, |a+2k|\geq 0$$ is equivalent to $$-1 \leq a+2k \leq 1$$ is equivalent to $$-\frac{1+a}{2}\leq k \leq \frac{1-a}{2}$$
Note that $\frac{1-a}{2}+\frac{1+a}{2}=1$, hence in the interval $[-\frac{1+a}{2},\frac{1-a}{2}]$ we are gonna have either $1$ or $2$ integers