FAILURE MAP
← Case archive

FA-17101 / Floating-point arithmetic / Open access

Same-sign midpoint separately halves subnormal endpoints · case 01

Same-sign midpoint separately halves subnormal endpoints.

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

ROOT CAUSE

Same-sign midpoint separately halves subnormal endpoints. The faulty expression is midpoint=a/2+b/2.

VERIFIED REPAIR

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

Unsuccessful approach: The attempted local correction midpoint=math.ldexp(a,-1)+math.ldexp(b,-1) 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/2+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 huge0x1.640306766bac8p+10230x1.640306766bac8p+1023Passed
negative huge-0x1.640306766bac8p+1023-0x1.640306766bac8p+1023Passed
subnormal midpoint0x0.0000000000002p-10220x0.0000000000003p-1022Failed
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 / aa499dd0c9df073f1ccfa0c0ef63a04e1ebf46b8ef20b7db475e07b094188d26

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=math.ldexp(a,-1)+math.ldexp(b,-1)
    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.0000000000002p-10220x0.0000000000003p-1022Failed
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 / ab4af1567a93ae15d12fe5afdf7f700a3ae44288850a83d78b909db4dc8dbe25

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.988954+00:00.

Case digest / 1d40e820ea1917fa06ff69b10cfdda2b453c6eb188298a49a5e974059b55dd6b