Using only addition, subtraction, multiplication, division, and "remainder" (modulo), can the absolute value of any integer be calculated?
To be explicit, I am hoping to find a method that does not involve a piecewise function (i.e. branching, if
, if you will.)
EDIT:
$$m=n\%(n^2-n+2)\\ p=m\%(n^2+2)\\ |n|=2p-n$$
If $n\ge0$ then $m=n$ and $p=n$.
If $n<0$ then $m=n^2+2$ and $p=0$.