FA-16591 / Floating-point arithmetic / Open access
Floating total order only flips the negative sign bit · case 01
Floating total order only flips the negative sign bit.
ROOT CAUSE
Floating total order only flips the negative sign bit. The faulty expression is return bits^(1<<63).
VERIFIED REPAIR
Apply the contract at this fault site using return ((~bits)&((1<<64)-1)) if bits>>63 else (bits|(1<<63)).
Unsuccessful approach: The attempted local correction return -(bits&((1<<63)-1)) if bits>>63 else bits still violates the explicit regression fixtures.
Case contract
Sort unsigned binary64 encodings by the stipulated IEEE-style total encoding order: negative NaNs, negative infinity, negative finite, negative zero, positive zero, positive finite, positive infinity, positive NaNs. Within signed NaNs, reversing bits on negatives reverses quietness and payload ordering. Preserve all encodings.
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(values):
def order(bits):
return bits^(1<<63)
return sorted(values,key=order)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero order', solve([0,1<<63]), [1<<63,0])
check('negative magnitudes', solve([0xbff0000000000000,0xc000000000000000]), [0xc000000000000000,0xbff0000000000000])
check('positive magnitudes', solve([0x4000000000000000,0x3ff0000000000000]), [0x3ff0000000000000,0x4000000000000000])
check('infinity and nan', solve([0x7ff8000000000000|N,0x7ff0000000000000]), [0x7ff0000000000000,0x7ff8000000000000|N])
check('negative nan order', solve([0xfff0000000000000|N,0xfff8000000000000|N]), [0xfff8000000000000|N,0xfff0000000000000|N])
check('positive payloads', solve([0x7ff8000000000064,0x7ff8000000000000|N]), [0x7ff8000000000000|N,0x7ff8000000000064])
check('negative payloads', solve([0xfff8000000000000|N,0xfff8000000000064]), [0xfff8000000000064,0xfff8000000000000|N])
check('mixed signs', solve([N,(1<<63)|N]), [(1<<63)|N,N])
check('duplicates', solve([N,N]), [N,N])
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 |
|---|---|---|---|
| zero order | [9223372036854775808, 0] | [9223372036854775808, 0] | Passed |
| negative magnitudes | [13830554455654793216, 13835058055282163712] | [13835058055282163712, 13830554455654793216] | Failed |
| positive magnitudes | [4607182418800017408, 4611686018427387904] | [4607182418800017408, 4611686018427387904] | Passed |
| infinity and nan | [9218868437227405312, 9221120237041090561] | [9218868437227405312, 9221120237041090561] | Passed |
| negative nan order | [18442240474082181121, 18444492273895866369] | [18444492273895866369, 18442240474082181121] | Failed |
| positive payloads | [9221120237041090561, 9221120237041090660] | [9221120237041090561, 9221120237041090660] | Passed |
| negative payloads | [18444492273895866369, 18444492273895866468] | [18444492273895866468, 18444492273895866369] | Failed |
| mixed signs | [9223372036854775809, 1] | [9223372036854775809, 1] | Passed |
| duplicates | [1, 1] | [1, 1] | Passed |
SHA-256 / b681932b5d0195f07c56a15de28ae7014e83d58201b0e2f02bcd622a607ac396
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(values):
def order(bits):
return -(bits&((1<<63)-1)) if bits>>63 else bits
return sorted(values,key=order)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero order', solve([0,1<<63]), [1<<63,0])
check('negative magnitudes', solve([0xbff0000000000000,0xc000000000000000]), [0xc000000000000000,0xbff0000000000000])
check('positive magnitudes', solve([0x4000000000000000,0x3ff0000000000000]), [0x3ff0000000000000,0x4000000000000000])
check('infinity and nan', solve([0x7ff8000000000000|N,0x7ff0000000000000]), [0x7ff0000000000000,0x7ff8000000000000|N])
check('negative nan order', solve([0xfff0000000000000|N,0xfff8000000000000|N]), [0xfff8000000000000|N,0xfff0000000000000|N])
check('positive payloads', solve([0x7ff8000000000064,0x7ff8000000000000|N]), [0x7ff8000000000000|N,0x7ff8000000000064])
check('negative payloads', solve([0xfff8000000000000|N,0xfff8000000000064]), [0xfff8000000000064,0xfff8000000000000|N])
check('mixed signs', solve([N,(1<<63)|N]), [(1<<63)|N,N])
check('duplicates', solve([N,N]), [N,N])
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 |
|---|---|---|---|
| zero order | [0, 9223372036854775808] | [9223372036854775808, 0] | Failed |
| negative magnitudes | [13835058055282163712, 13830554455654793216] | [13835058055282163712, 13830554455654793216] | Passed |
| positive magnitudes | [4607182418800017408, 4611686018427387904] | [4607182418800017408, 4611686018427387904] | Passed |
| infinity and nan | [9218868437227405312, 9221120237041090561] | [9218868437227405312, 9221120237041090561] | Passed |
| negative nan order | [18444492273895866369, 18442240474082181121] | [18444492273895866369, 18442240474082181121] | Passed |
| positive payloads | [9221120237041090561, 9221120237041090660] | [9221120237041090561, 9221120237041090660] | Passed |
| negative payloads | [18444492273895866468, 18444492273895866369] | [18444492273895866468, 18444492273895866369] | Passed |
| mixed signs | [9223372036854775809, 1] | [9223372036854775809, 1] | Passed |
| duplicates | [1, 1] | [1, 1] | Passed |
SHA-256 / 5c4515172805da372c387f57fbd58a25509533e7ae254ab5aaeee953158b2b71
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(values):
def order(bits):
return ((~bits)&((1<<64)-1)) if bits>>63 else (bits|(1<<63))
return sorted(values,key=order)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero order', solve([0,1<<63]), [1<<63,0])
check('negative magnitudes', solve([0xbff0000000000000,0xc000000000000000]), [0xc000000000000000,0xbff0000000000000])
check('positive magnitudes', solve([0x4000000000000000,0x3ff0000000000000]), [0x3ff0000000000000,0x4000000000000000])
check('infinity and nan', solve([0x7ff8000000000000|N,0x7ff0000000000000]), [0x7ff0000000000000,0x7ff8000000000000|N])
check('negative nan order', solve([0xfff0000000000000|N,0xfff8000000000000|N]), [0xfff8000000000000|N,0xfff0000000000000|N])
check('positive payloads', solve([0x7ff8000000000064,0x7ff8000000000000|N]), [0x7ff8000000000000|N,0x7ff8000000000064])
check('negative payloads', solve([0xfff8000000000000|N,0xfff8000000000064]), [0xfff8000000000064,0xfff8000000000000|N])
check('mixed signs', solve([N,(1<<63)|N]), [(1<<63)|N,N])
check('duplicates', solve([N,N]), [N,N])
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 |
|---|---|---|---|
| zero order | [9223372036854775808, 0] | [9223372036854775808, 0] | Passed |
| negative magnitudes | [13835058055282163712, 13830554455654793216] | [13835058055282163712, 13830554455654793216] | Passed |
| positive magnitudes | [4607182418800017408, 4611686018427387904] | [4607182418800017408, 4611686018427387904] | Passed |
| infinity and nan | [9218868437227405312, 9221120237041090561] | [9218868437227405312, 9221120237041090561] | Passed |
| negative nan order | [18444492273895866369, 18442240474082181121] | [18444492273895866369, 18442240474082181121] | Passed |
| positive payloads | [9221120237041090561, 9221120237041090660] | [9221120237041090561, 9221120237041090660] | Passed |
| negative payloads | [18444492273895866468, 18444492273895866369] | [18444492273895866468, 18444492273895866369] | Passed |
| mixed signs | [9223372036854775809, 1] | [9223372036854775809, 1] | Passed |
| duplicates | [1, 1] | [1, 1] | Passed |
SHA-256 / 63936deb9efcf833d064d15cba3f033e86676025c33703575b243fb2a1586d24
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:37.899530+00:00.
Case digest / 713810e5a0548bed57ce131f55c713bfb83dc19ec3a26898312f1c6d044f9af3