FA-16081 / Floating-point arithmetic / Open access
ULP distance validates only its right operand · case 01
ULP distance validates only its right operand.
ROOT CAUSE
ULP distance validates only its right operand. The faulty expression is if not math.isfinite(b): return None.
VERIFIED REPAIR
Apply the contract at this fault site using if not math.isfinite(a) or not math.isfinite(b): return None.
Unsuccessful approach: The attempted local correction if math.isinf(a) or not math.isfinite(b): return None still violates the explicit regression fixtures.
Case contract
Distance between finite binary64 values in representable steps, treating the two zeros as a single position; NaN or infinity yields null. Negative and positive subnormals are adjacent through zero.
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 not math.isfinite(b): return None
ab=int.from_bytes(struct.pack('>d',a),'big')
bb=int.from_bytes(struct.pack('>d',b),'big')
a_index=-(ab&((1<<63)-1)) if ab>>63 else ab
b_index=-(bb&((1<<63)-1)) if bb>>63 else bb
return abs(a_index-b_index)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('same', solve(float(N),float(N)), 0)
check('zero signs', solve(-0.0,0.0), 0)
check('negative adjacent', solve(-float(N),math.nextafter(-float(N),-math.inf)), 1)
check('positive adjacent', solve(float(N),math.nextafter(float(N),math.inf)), 1)
check('cross zero', solve(-math.ldexp(float(N),-1074),math.ldexp(float(N),-1074)), 2*N)
check('reverse cross', solve(math.ldexp(float(N),-1074),-math.ldexp(float(N),-1074)), 2*N)
check('nan left', solve(float("nan"),1.0), None)
check('nan right', solve(1.0,float("nan")), None)
check('infinity', solve(math.inf,math.inf), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| same | 0 | 0 | Passed |
| zero signs | 0 | 0 | Passed |
| negative adjacent | 1 | 1 | Passed |
| positive adjacent | 1 | 1 | Passed |
| cross zero | 2 | 2 | Passed |
| reverse cross | 2 | 2 | Passed |
| nan left | 4613937818241073152 | None | Failed |
| nan right | None | None | Passed |
| infinity | None | None | Passed |
SHA-256 / c63df46af981a5eda15e4bca9398af0062fc2822518f8c45a62288e49c3a726e
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 math.isinf(a) or not math.isfinite(b): return None
ab=int.from_bytes(struct.pack('>d',a),'big')
bb=int.from_bytes(struct.pack('>d',b),'big')
a_index=-(ab&((1<<63)-1)) if ab>>63 else ab
b_index=-(bb&((1<<63)-1)) if bb>>63 else bb
return abs(a_index-b_index)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('same', solve(float(N),float(N)), 0)
check('zero signs', solve(-0.0,0.0), 0)
check('negative adjacent', solve(-float(N),math.nextafter(-float(N),-math.inf)), 1)
check('positive adjacent', solve(float(N),math.nextafter(float(N),math.inf)), 1)
check('cross zero', solve(-math.ldexp(float(N),-1074),math.ldexp(float(N),-1074)), 2*N)
check('reverse cross', solve(math.ldexp(float(N),-1074),-math.ldexp(float(N),-1074)), 2*N)
check('nan left', solve(float("nan"),1.0), None)
check('nan right', solve(1.0,float("nan")), None)
check('infinity', solve(math.inf,math.inf), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| same | 0 | 0 | Passed |
| zero signs | 0 | 0 | Passed |
| negative adjacent | 1 | 1 | Passed |
| positive adjacent | 1 | 1 | Passed |
| cross zero | 2 | 2 | Passed |
| reverse cross | 2 | 2 | Passed |
| nan left | 4613937818241073152 | None | Failed |
| nan right | None | None | Passed |
| infinity | None | None | Passed |
SHA-256 / de6e32076b162cf029649781fed1c8bd4153003e329153c7998204773baa06ad
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 not math.isfinite(a) or not math.isfinite(b): return None
ab=int.from_bytes(struct.pack('>d',a),'big')
bb=int.from_bytes(struct.pack('>d',b),'big')
a_index=-(ab&((1<<63)-1)) if ab>>63 else ab
b_index=-(bb&((1<<63)-1)) if bb>>63 else bb
return abs(a_index-b_index)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('same', solve(float(N),float(N)), 0)
check('zero signs', solve(-0.0,0.0), 0)
check('negative adjacent', solve(-float(N),math.nextafter(-float(N),-math.inf)), 1)
check('positive adjacent', solve(float(N),math.nextafter(float(N),math.inf)), 1)
check('cross zero', solve(-math.ldexp(float(N),-1074),math.ldexp(float(N),-1074)), 2*N)
check('reverse cross', solve(math.ldexp(float(N),-1074),-math.ldexp(float(N),-1074)), 2*N)
check('nan left', solve(float("nan"),1.0), None)
check('nan right', solve(1.0,float("nan")), None)
check('infinity', solve(math.inf,math.inf), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| same | 0 | 0 | Passed |
| zero signs | 0 | 0 | Passed |
| negative adjacent | 1 | 1 | Passed |
| positive adjacent | 1 | 1 | Passed |
| cross zero | 2 | 2 | Passed |
| reverse cross | 2 | 2 | Passed |
| nan left | None | None | Passed |
| nan right | None | None | Passed |
| infinity | None | None | Passed |
SHA-256 / b4444a40538d6b1c2937a3fd331d44cb409920423aaa46f429612d1c2911aa1c
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:32.860103+00:00.
Case digest / c504f8fb42e121fb6c8cebe18486915136672d2c7a72cf7b2b1a619ea66b8eea