= Solution
For the exact difference, the representability condition becomes
$$
\boxed{-H\leq x-y\leq U\quad\Longleftrightarrow\quad x-U\leq y\leq x+H.}
$$
Within the same operand square $[-H,U]^2$, the closed diagonal band between $y=x-U$ and $y=x+H$ is representable. Above the upper line, $x-y<-H$ gives negative overflow; below the lower line, $x-y>U$ gives positive overflow. The right-hand panel of the figure shows these regions, including their representable boundary points.
Positive overflow can occur only when $x\geq0$ and $y<0$; negative overflow can occur only when $x<0$ and $y\geq0$. The corresponding exact inequalities are still required: operands with different signs do not always overflow. Same-sign subtraction is always representable. In sign-<bit> terms, subtraction overflows exactly when the operands have different signs and the wrapped result's sign differs from that of $x$.
One must test subtraction directly or use its correct overflow rule: forming `-y` in the same $n$ <bits> fails at $y=-H$, even though some differences with that operand are representable. For example $(-H)-(-H)=0$ is valid.
Back to article page