I'm reading Concrete Mathematics. The problem is from Exercise 3.2 of this book.
The answer is pretty obvious
$$ \lfloor x + 0.5\rfloor, \text{if \{x\} = 0.5 then ceil should be considered}\\ \lceil x - 0.5 \rceil, \text{if \{x\} = 0.5 then floor should be considered} $$ where {x} = fractional part of x
The problem is I'm not able to prove the above equations. How to prove it ?
Since $\lfloor y\rfloor \le y<\lfloor y\rfloor+1$ and there does not exist an integer $n$ with $\lfloor y\rfloor <n<\lfloor y\rfloor+1$, the only candidates for the nearest integer to $y$ are $\lfloor y\rfloor$ and $\lfloor y\rfloor+1$. The distances are $|y-\lfloor y\rfloor|=y-\lfloor y\rfloor =\{y\}$ and $|y-\lfloor y\rfloor-1|=1-y+\lfloor y\rfloor =1-\{y\}$, respectively. To find the nearest, we have to compare $\{y\}$ against $1-\{y\}$ or equivalently, $2\{y\}$ againts $1$. Thus
Remains to show that these piecewise definitions coincide with $\lfloor y+\frac12\rfloor$ (the treatment of $\lceil y-\frac12\rceil$ is similar).
In summary, for all $y\in\Bbb R$, $\lfloor y+\frac12\rfloor$ is a nearest integer of $y$.