Given two integers $a$ and $b$ with the relation $a<=b$, and a third number $x$ between them $a<=x<=b$, find the number which is closest to $x$, either $a$ or $b$, without using comparisons.
The permitted integer operations are : additions, multiplications, subtractions, exponentiation and any operation in a field or ring (not division). The purpose is to avoid using comparison operators like $<$ or $>$, but if they can be implemented using only the permitted operations is fine.
Basically, the puzzle consist in designing a function that :
$f(x,a,b)=\begin{cases} b, abs(x-a)\geq abs(x-b)\\ a, abs(x-a)\lt abs(x-b) \end{cases}$
where $abs(x-a)$ is the absolute value of the $x-a$, namely the distance between $x$ and $a$.