FAILURE MAP
← Case archive

FA-16551 / Floating-point arithmetic / Open access

Signaling NaN addition fails to raise invalid · case 01

Signaling NaN addition fails to raise invalid.

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

ROOT CAUSE

Signaling NaN addition fails to raise invalid. The faulty expression is return [chosen|(1<<51),False].

THE FAILURE

Signaling NaN addition fails to raise invalid. The faulty expression is return [chosen|(1<<51),False].

Unsuccessful approach: The attempted local correction return [chosen|(1<<51),bool(asig and bsig)] still violates the explicit regression fixtures.

Case contract

Stipulated binary64 addition policy: propagate first signaling NaN, otherwise largest quiet-NaN diagnostic payload (left wins ties); quiet propagated NaNs preserving sign. Opposite infinities produce canonical quiet NaN. Finite values use Python binary64 addition. Return bits and invalid flag.

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(ab,bb):
    mask=(1<<52)-1
    an=(ab>>52)&2047==2047 and bool(ab&mask)
    bn=(bb>>52)&2047==2047 and bool(bb&mask)
    asig=an and not bool(ab&(1<<51))
    bsig=bn and not bool(bb&(1<<51))
    if asig or bsig:
        chosen=ab if asig else bb
        return [chosen|(1<<51),False]
    if an or bn:
        if an and bn:
            chosen=ab if (ab&((1<<51)-1)) >= (bb&((1<<51)-1)) else bb
        else:
            chosen=ab if an else bb
        return [chosen,False]
    a=struct.unpack('>d',ab.to_bytes(8,'big'))[0]
    b=struct.unpack('>d',bb.to_bytes(8,'big'))[0]
    if math.isinf(a) and math.isinf(b) and a!=b:
        return [0x7ff8000000000000,True]
    result=a+b
    return [int.from_bytes(struct.pack('>d',result),'big'),False]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('left signaling', solve(0x7ff0000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,True])
check('right signaling', solve(0x3ff0000000000000,0xfff0000000000000|N), [0xfff8000000000000|N,True])
check('signaling precedence', solve(0x7ff8000000000064,0x7ff0000000000000|N), [0x7ff8000000000000|N,True])
check('two signaling', solve(0xfff0000000000000|N,0x7ff0000000000010), [0xfff8000000000000|N,True])
check('larger right payload', solve(0x7ff8000000000000|N,0xfff8000000000064), [0xfff8000000000064,False])
check('larger left payload', solve(0xfff8000000000064,0x7ff8000000000000|N), [0xfff8000000000064,False])
check('equal left wins', solve(0xfff8000000000000|N,0x7ff8000000000000|N), [0xfff8000000000000|N,False])
check('positive quiet', solve(0x7ff8000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,False])
check('quiet left only', solve(0xfff8000000000000|N,0x3ff0000000000000), [0xfff8000000000000|N,False])
check('quiet right only', solve(0x3ff0000000000000,0xfff8000000000000|N), [0xfff8000000000000|N,False])
check('opposite infinities', solve(0x7ff0000000000000,0xfff0000000000000), [0x7ff8000000000000,True])
check('same infinity', solve(0xfff0000000000000,0xfff0000000000000), [0xfff0000000000000,False])
check('finite addition', solve(0x3ff0000000000000,0x3ff0000000000000), [0x4000000000000000,False])
check('negative zeros', solve(1<<63,1<<63), [1<<63,False])
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
left signaling[9221120237041090561, False][9221120237041090561, True]Failed
right signaling[18444492273895866369, False][18444492273895866369, True]Failed
signaling precedence[9221120237041090561, False][9221120237041090561, True]Failed
two signaling[18444492273895866369, False][18444492273895866369, True]Failed
larger right payload[18444492273895866468, False][18444492273895866468, False]Passed
larger left payload[18444492273895866468, False][18444492273895866468, False]Passed
equal left wins[18444492273895866369, False][18444492273895866369, False]Passed
positive quiet[9221120237041090561, False][9221120237041090561, False]Passed
quiet left only[18444492273895866369, False][18444492273895866369, False]Passed
quiet right only[18444492273895866369, False][18444492273895866369, False]Passed
opposite infinities[9221120237041090560, True][9221120237041090560, True]Passed
same infinity[18442240474082181120, False][18442240474082181120, False]Passed
finite addition[4611686018427387904, False][4611686018427387904, False]Passed
negative zeros[9223372036854775808, False][9223372036854775808, False]Passed

SHA-256 / 88c45b3d8d7a942578b5cb4506c69bd0406a6b637cfd9595ff37e283154c832b

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(ab,bb):
    mask=(1<<52)-1
    an=(ab>>52)&2047==2047 and bool(ab&mask)
    bn=(bb>>52)&2047==2047 and bool(bb&mask)
    asig=an and not bool(ab&(1<<51))
    bsig=bn and not bool(bb&(1<<51))
    if asig or bsig:
        chosen=ab if asig else bb
        return [chosen|(1<<51),bool(asig and bsig)]
    if an or bn:
        if an and bn:
            chosen=ab if (ab&((1<<51)-1)) >= (bb&((1<<51)-1)) else bb
        else:
            chosen=ab if an else bb
        return [chosen,False]
    a=struct.unpack('>d',ab.to_bytes(8,'big'))[0]
    b=struct.unpack('>d',bb.to_bytes(8,'big'))[0]
    if math.isinf(a) and math.isinf(b) and a!=b:
        return [0x7ff8000000000000,True]
    result=a+b
    return [int.from_bytes(struct.pack('>d',result),'big'),False]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('left signaling', solve(0x7ff0000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,True])
check('right signaling', solve(0x3ff0000000000000,0xfff0000000000000|N), [0xfff8000000000000|N,True])
check('signaling precedence', solve(0x7ff8000000000064,0x7ff0000000000000|N), [0x7ff8000000000000|N,True])
check('two signaling', solve(0xfff0000000000000|N,0x7ff0000000000010), [0xfff8000000000000|N,True])
check('larger right payload', solve(0x7ff8000000000000|N,0xfff8000000000064), [0xfff8000000000064,False])
check('larger left payload', solve(0xfff8000000000064,0x7ff8000000000000|N), [0xfff8000000000064,False])
check('equal left wins', solve(0xfff8000000000000|N,0x7ff8000000000000|N), [0xfff8000000000000|N,False])
check('positive quiet', solve(0x7ff8000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,False])
check('quiet left only', solve(0xfff8000000000000|N,0x3ff0000000000000), [0xfff8000000000000|N,False])
check('quiet right only', solve(0x3ff0000000000000,0xfff8000000000000|N), [0xfff8000000000000|N,False])
check('opposite infinities', solve(0x7ff0000000000000,0xfff0000000000000), [0x7ff8000000000000,True])
check('same infinity', solve(0xfff0000000000000,0xfff0000000000000), [0xfff0000000000000,False])
check('finite addition', solve(0x3ff0000000000000,0x3ff0000000000000), [0x4000000000000000,False])
check('negative zeros', solve(1<<63,1<<63), [1<<63,False])
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
left signaling[9221120237041090561, False][9221120237041090561, True]Failed
right signaling[18444492273895866369, False][18444492273895866369, True]Failed
signaling precedence[9221120237041090561, False][9221120237041090561, True]Failed
two signaling[18444492273895866369, True][18444492273895866369, True]Passed
larger right payload[18444492273895866468, False][18444492273895866468, False]Passed
larger left payload[18444492273895866468, False][18444492273895866468, False]Passed
equal left wins[18444492273895866369, False][18444492273895866369, False]Passed
positive quiet[9221120237041090561, False][9221120237041090561, False]Passed
quiet left only[18444492273895866369, False][18444492273895866369, False]Passed
quiet right only[18444492273895866369, False][18444492273895866369, False]Passed
opposite infinities[9221120237041090560, True][9221120237041090560, True]Passed
same infinity[18442240474082181120, False][18442240474082181120, False]Passed
finite addition[4611686018427387904, False][4611686018427387904, False]Passed
negative zeros[9223372036854775808, False][9223372036854775808, False]Passed

SHA-256 / 1a28582fec1df937826eaa35d89cd2feb5401935775f6a244c97276f6e446793

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 14 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:37.678459+00:00.

Case digest / bd1167fa127ce0d2b7ad43b304674eecbd2f4122080090c598dfcb0b8960a84d