FAILURE MAP
← Case archive

FA-16096 / Floating-point arithmetic / Open access

ULP distance complements the second negative encoding without zero alignment · case 01

ULP distance complements the second negative encoding without zero alignment.

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

ROOT CAUSE

ULP distance complements the second negative encoding without zero alignment. The faulty expression is b_index=~bb if bb>>63 else bb.

THE FAILURE

ULP distance complements the second negative encoding without zero alignment. The faulty expression is b_index=~bb if bb>>63 else bb.

Unsuccessful approach: The attempted local correction b_index=bb 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(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 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 fixtureActualExpectedOutcome
same00Passed
zero signs00Passed
negative adjacent92233720368547758101Failed
positive adjacent11Passed
cross zero22Passed
reverse cross92233720368547758112Failed
nan leftNoneNonePassed
nan rightNoneNonePassed
infinityNoneNonePassed

SHA-256 / 6d36497fb42b9da20d1178ede522045f3e253dd9b479247001048d4f0c3281aa

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 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
    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 fixtureActualExpectedOutcome
same00Passed
zero signs00Passed
negative adjacent184377368744548106251Failed
positive adjacent11Passed
cross zero22Passed
reverse cross92233720368547758082Failed
nan leftNoneNonePassed
nan rightNoneNonePassed
infinityNoneNonePassed

SHA-256 / 1bf27baa9ab3ccd4c99dc2db756c660bfde875edcfdc36e07874f1b44086efd8

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 9 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / ba39a1654cc8affb203c6bc9499618cb1abf3b1691afec5812d3a806fdd04f16