FAILURE MAP
← Case archive

FA-17096 / Floating-point arithmetic / Open access

Same-sign midpoint overflows its endpoint sum · case 01

Same-sign midpoint overflows its endpoint sum.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Same-sign midpoint overflows its endpoint sum. The faulty expression is midpoint=(a+b)/2.

VERIFIED REPAIR

Apply the contract at this fault site using midpoint=a+(b-a)/2.

Unsuccessful approach: The attempted local correction midpoint=min(a+b,1e308)/2 still violates the explicit regression fixtures.

Case contract

Finite ordered binary64 midpoint rendered as hex. Opposite-sign endpoints use half-sums to avoid difference overflow; same-sign endpoints use a difference to preserve subnormal increments. Exact equal endpoints preserve their bits.

Why this case matters

An offline floating representation model isolates a reproducible arithmetic fault.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(a,b):
    if a>b: return 'invalid'
    if a==b: return a.hex()
    if a<0<b:
        midpoint=a/2+b/2
    else:
        midpoint=(a+b)/2
    return midpoint.hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('opposite huge', solve(-1e308,1e308), 0.0.hex())
check('positive huge', solve(1e308,1.5e308), (1.25e308).hex())
check('negative huge', solve(-1.5e308,-1e308), (-1.25e308).hex())
check('subnormal midpoint', solve(math.ldexp(1.0,-1074),math.ldexp(5.0,-1074)), math.ldexp(3.0,-1074).hex())
check('subnormal same', solve(math.ldexp(1.0,-1074),math.ldexp(3.0,-1074)), math.ldexp(2.0,-1074).hex())
check('negative subnormal', solve(-math.ldexp(3.0,-1074),-math.ldexp(1.0,-1074)), (-math.ldexp(2.0,-1074)).hex())
check('negative zero equal', solve(-0.0,-0.0), (-0.0).hex())
check('ordinary', solve(float(N),float(N+8)), float(N+4).hex())
check('reverse', solve(float(N+1),float(N)), "invalid")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
opposite huge0x0.0p+00x0.0p+0Passed
positive hugeinf0x1.640306766bac8p+1023Failed
negative huge-inf-0x1.640306766bac8p+1023Failed
subnormal midpoint0x0.0000000000003p-10220x0.0000000000003p-1022Passed
subnormal same0x0.0000000000002p-10220x0.0000000000002p-1022Passed
negative subnormal-0x0.0000000000002p-1022-0x0.0000000000002p-1022Passed
negative zero equal-0x0.0p+0-0x0.0p+0Passed
ordinary0x1.4000000000000p+20x1.4000000000000p+2Passed
reverseinvalidinvalidPassed

SHA-256 / 5a55baf3c2f580dda5cbf41750240c478bbb73f203136d63053477c97a4e9382

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(a,b):
    if a>b: return 'invalid'
    if a==b: return a.hex()
    if a<0<b:
        midpoint=a/2+b/2
    else:
        midpoint=min(a+b,1e308)/2
    return midpoint.hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('opposite huge', solve(-1e308,1e308), 0.0.hex())
check('positive huge', solve(1e308,1.5e308), (1.25e308).hex())
check('negative huge', solve(-1.5e308,-1e308), (-1.25e308).hex())
check('subnormal midpoint', solve(math.ldexp(1.0,-1074),math.ldexp(5.0,-1074)), math.ldexp(3.0,-1074).hex())
check('subnormal same', solve(math.ldexp(1.0,-1074),math.ldexp(3.0,-1074)), math.ldexp(2.0,-1074).hex())
check('negative subnormal', solve(-math.ldexp(3.0,-1074),-math.ldexp(1.0,-1074)), (-math.ldexp(2.0,-1074)).hex())
check('negative zero equal', solve(-0.0,-0.0), (-0.0).hex())
check('ordinary', solve(float(N),float(N+8)), float(N+4).hex())
check('reverse', solve(float(N+1),float(N)), "invalid")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
opposite huge0x0.0p+00x0.0p+0Passed
positive huge0x1.1ccf385ebc8a0p+10220x1.640306766bac8p+1023Failed
negative huge-inf-0x1.640306766bac8p+1023Failed
subnormal midpoint0x0.0000000000003p-10220x0.0000000000003p-1022Passed
subnormal same0x0.0000000000002p-10220x0.0000000000002p-1022Passed
negative subnormal-0x0.0000000000002p-1022-0x0.0000000000002p-1022Passed
negative zero equal-0x0.0p+0-0x0.0p+0Passed
ordinary0x1.4000000000000p+20x1.4000000000000p+2Passed
reverseinvalidinvalidPassed

SHA-256 / 3f316681cc304f1792fd1110fd38fcc7dadce1234c50da40855e11d9a553a7d3

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(a,b):
    if a>b: return 'invalid'
    if a==b: return a.hex()
    if a<0<b:
        midpoint=a/2+b/2
    else:
        midpoint=a+(b-a)/2
    return midpoint.hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('opposite huge', solve(-1e308,1e308), 0.0.hex())
check('positive huge', solve(1e308,1.5e308), (1.25e308).hex())
check('negative huge', solve(-1.5e308,-1e308), (-1.25e308).hex())
check('subnormal midpoint', solve(math.ldexp(1.0,-1074),math.ldexp(5.0,-1074)), math.ldexp(3.0,-1074).hex())
check('subnormal same', solve(math.ldexp(1.0,-1074),math.ldexp(3.0,-1074)), math.ldexp(2.0,-1074).hex())
check('negative subnormal', solve(-math.ldexp(3.0,-1074),-math.ldexp(1.0,-1074)), (-math.ldexp(2.0,-1074)).hex())
check('negative zero equal', solve(-0.0,-0.0), (-0.0).hex())
check('ordinary', solve(float(N),float(N+8)), float(N+4).hex())
check('reverse', solve(float(N+1),float(N)), "invalid")
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
opposite huge0x0.0p+00x0.0p+0Passed
positive huge0x1.640306766bac8p+10230x1.640306766bac8p+1023Passed
negative huge-0x1.640306766bac8p+1023-0x1.640306766bac8p+1023Passed
subnormal midpoint0x0.0000000000003p-10220x0.0000000000003p-1022Passed
subnormal same0x0.0000000000002p-10220x0.0000000000002p-1022Passed
negative subnormal-0x0.0000000000002p-1022-0x0.0000000000002p-1022Passed
negative zero equal-0x0.0p+0-0x0.0p+0Passed
ordinary0x1.4000000000000p+20x1.4000000000000p+2Passed
reverseinvalidinvalidPassed

SHA-256 / 0012a90273b46b3f5e0d0c84c54b3347f32324dff9ac8f78b39bd3527c153291

Verification & scope

Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:39:42.986768+00:00.

Case digest / 2a4029b91e46fc8eaab3231086bb1e0a8e470105e383246cb586f1f00c6bb506