broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=set() if clear else accrued
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=new & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued & set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["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)

prompt:
Clearing one floating flag clears all accrued flags.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=(new-set(clear)) & set(enabled)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(sticky, enabled, raised, clear):
    priority=['invalid','divzero','overflow','underflow','inexact']
    prior=set(sticky)
    new=set(raised)
    if 'overflow' in new: new.add('inexact')
    if 'underflow' in new: new.add('inexact')
    accrued=prior|new
    pending=(new|set(clear)) & set(enabled)-set(clear)
    trap=next((flag for flag in priority if flag in pending),None)
    remaining=accrued-set(clear)
    return [sorted(prior),sorted(accrued),trap,sorted(remaining)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sticky survives', solve(["invalid"],[],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('overflow implies inexact', solve([],[],["overflow"],[]), [[],["inexact","overflow"],None,["inexact","overflow"]])
check('underflow implies inexact', solve([],[],["underflow"],[]), [[],["inexact","underflow"],None,["inexact","underflow"]])
check('priority', solve([],["overflow","invalid"],["overflow","invalid"],[]), [[],["inexact","invalid","overflow"],"invalid",["inexact","invalid","overflow"]])
check('old flag no retrap', solve(["invalid"],["invalid"],["inexact"],[]), [["invalid"],["inexact","invalid"],None,["inexact","invalid"]])
check('clear after trap', solve([],["divzero"],["divzero"],["divzero"]), [[],["divzero"],"divzero",[]])
check('selective clear', solve(["invalid","inexact"],[],[],["inexact"]), [["inexact","invalid"],["inexact","invalid"],None,["invalid"]])
check('masked flag still sticky', solve([],[],["divzero"],[]), [[],["divzero"],None,["divzero"]])
check('five distinct flag sets', solve([],[],["invalid","divzero","inexact","underflow","overflow"][:N],[]), [[],sorted(["invalid","divzero","inexact","underflow","overflow"][:N]),None,sorted(["invalid","divzero","inexact","underflow","overflow"][:N])])
check('empty operation', solve(["inexact"] if N%2 else ["invalid"],[],[],[]), [["inexact"] if N%2 else ["invalid"],["inexact"] if N%2 else ["invalid"],None,["inexact"] if N%2 else ["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)

prompt:
Cleared floating flags are suppressed before trap reporting.

Stipulated floating exception environment: apply an operation flag set, accrue sticky flags, select enabled trap by priority invalid/divzero/overflow/underflow/inexact, save prior state and clear only requested flags after reporting the trap. Inputs are valid flag names.

split: open-access


broken_source:
"""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 an else bb
        return [chosen|(1<<51),True]
    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)

source:
"""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=bb if bn else ab
        return [chosen|(1<<51),True]
    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)

prompt:
NaN addition lets a quiet left operand hide a signaling right operand.

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.

split: open-access


broken_source:
"""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,True]
    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)

source:
"""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 [0x7ff8000000000000,True]
    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)

prompt:
NaN propagation returns a signaling encoding unchanged.

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.

split: open-access


broken_source:
"""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)

source:
"""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)

prompt:
Signaling NaN addition fails to raise invalid.

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.

split: open-access


broken_source:
"""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),True]
    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)

source:
"""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),True]
    if an or bn:
        if an and bn:
            chosen=ab
        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)

prompt:
Quiet NaN addition selects the smaller diagnostic payload.

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.

split: open-access


broken_source:
"""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),True]
    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)

source:
"""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),True]
    if an or bn:
        if an and bn:
            chosen=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)

prompt:
Quiet NaN addition breaks a diagnostic tie toward the right operand.

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.

split: open-access


broken_source:
"""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),True]
    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&((1<<63)-1),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)

source:
"""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),True]
    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|(1<<63),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)

prompt:
Quiet NaN propagation strips its diagnostic sign.

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.

split: open-access


broken_source:
"""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),True]
    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,True]
    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)

source:
"""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),True]
    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,an and bn]
    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)

prompt:
Quiet NaN propagation raises invalid without signaling input.

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.

split: open-access


broken_source:
"""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),True]
    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,False]
    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)

source:
"""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),True]
    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 [0x7ff0000000000000,False]
    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)

prompt:
Opposite infinities fail to raise invalid on addition.

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.

split: open-access


broken_source:
"""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),True]
    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):
        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)

source:
"""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),True]
    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) or math.isinf(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)

prompt:
Infinity addition treats equal signs as invalid.

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.

split: open-access


broken_source:
"""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
    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)

source:
"""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)
    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)

prompt:
Floating total order sorts raw unsigned encodings.

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.

split: open-access


broken_source:
"""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)

source:
"""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)

prompt:
Floating total order only flips the negative sign bit.

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.

split: open-access


broken_source:
"""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
    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)

source:
"""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)
    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)

prompt:
Floating total order omits the positive sign-domain offset.

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.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(values):
    def order(bits):
        return struct.unpack(">d",bits.to_bytes(8,"big"))[0]
    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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(values):
    def order(bits):
        return abs(struct.unpack(">d",bits.to_bytes(8,"big"))[0])
    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)

prompt:
Floating total order compares decoded numeric values.

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.

split: open-access


broken_source:
"""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(set(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)

source:
"""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 list(dict.fromkeys(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)

prompt:
Floating total-order sorting drops repeated encodings.

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.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|1
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio conversion omits the normal hidden bit.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023+52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio conversion forgets the fraction binary point.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1022
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1075
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio conversion scales subnormals as normal mantissas.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,0]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [sign,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio conversion returns a zero denominator for zero.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa>1:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==1:
        mantissa//=2
        power+=1
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio conversion removes factors of two from odd mantissas.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=2
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
    sign=-1 if bits>>63 else 1
    e=(bits>>52)&2047
    f=bits&((1<<52)-1)
    if e==2047: return None
    if e:
        mantissa=f|(1<<52)
        power=e-1023-52
    else:
        mantissa=f
        power=-1074
    if mantissa==0: return [0,1]
    while power<0 and mantissa%2==0:
        mantissa//=2
        power+=0
    if power>=0: return [sign*(mantissa<<power),1]
    return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), 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)

prompt:
Exact ratio reduction moves exponent in the wrong direction.

Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.

split: open-access