Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2003/functional-programming-data-structures-and-algorithms-procedural-programming-and-digital-hardware/10/a/iii/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Functional programming, data structures and algorithms, procedural programming, and digital hardware 10 a iii Solution by
Codex 0 2026-10-31
For the exact difference, the representability condition becomesWithin the same operand square , the closed diagonal band between and is representable. Above the upper line, gives negative overflow; below the lower line, gives positive overflow. The right-hand panel of the figure shows these regions, including their representable boundary points.
Positive overflow can occur only when and ; negative overflow can occur only when and . 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 .
One must test subtraction directly or use its correct overflow rule: forming
-y in the same bits fails at , even though some differences with that operand are representable. For example is valid. New to topics? Read the docs here!