prompt:
The exact finite field discrete transform result violates the stated contract at transform normalization convention.

Input [values,p,w], len(values)=n and w has exact multiplicative order n modulo prime p; forward transform sum values[j]*w^(j*k) modulo p.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
The exact walsh hadamard transform result violates the stated contract at butterfly stage termination.

Input integer list of power-of-two length; return unnormalized Sylvester-ordered Walsh-Hadamard transform. Bounds: length<=1024.

split: open-access


prompt:
The exact walsh hadamard transform result violates the stated contract at butterfly block stride.

Input integer list of power-of-two length; return unnormalized Sylvester-ordered Walsh-Hadamard transform. Bounds: length<=1024.

split: open-access


prompt:
The exact walsh hadamard transform result violates the stated contract at sum wing.

Input integer list of power-of-two length; return unnormalized Sylvester-ordered Walsh-Hadamard transform. Bounds: length<=1024.

split: open-access


prompt:
The exact walsh hadamard transform result violates the stated contract at difference wing.

Input integer list of power-of-two length; return unnormalized Sylvester-ordered Walsh-Hadamard transform. Bounds: length<=1024.

split: open-access


prompt:
The exact walsh hadamard transform result violates the stated contract at butterfly span growth.

Input integer list of power-of-two length; return unnormalized Sylvester-ordered Walsh-Hadamard transform. Bounds: length<=1024.

split: open-access


prompt:
The exact montgomery residue product result violates the stated contract at negative modulus inverse.

Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.

split: open-access


prompt:
The exact montgomery residue product result violates the stated contract at wide product retention.

Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.

split: open-access


prompt:
The exact montgomery residue product result violates the stated contract at low radix correction.

Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.

split: open-access


prompt:
The exact montgomery residue product result violates the stated contract at radix cancellation quotient.

Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.

split: open-access


prompt:
The exact montgomery residue product result violates the stated contract at final conditional subtraction.

Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.

split: open-access


prompt:
The exact singular hensel root tree result violates the stated contract at root tree lift depth.

Input [polynomial coefficients,p,k], p prime and k>=1; enumerate all roots modulo p^k, including singular roots.

split: open-access


prompt:
The exact singular hensel root tree result violates the stated contract at root tree target modulus.

Input [polynomial coefficients,p,k], p prime and k>=1; enumerate all roots modulo p^k, including singular roots.

split: open-access


prompt:
The exact singular hensel root tree result violates the stated contract at all extension digits.

Input [polynomial coefficients,p,k], p prime and k>=1; enumerate all roots modulo p^k, including singular roots.

split: open-access


prompt:
The exact singular hensel root tree result violates the stated contract at root residue digit placement.

Input [polynomial coefficients,p,k], p prime and k>=1; enumerate all roots modulo p^k, including singular roots.

split: open-access


prompt:
The exact singular hensel root tree result violates the stated contract at lifted polynomial congruence.

Input [polynomial coefficients,p,k], p prime and k>=1; enumerate all roots modulo p^k, including singular roots.

split: open-access


prompt:
The exact tonelli shanks square root result violates the stated contract at nonresidue subgroup generator.

Input [a,p], odd prime p and nonzero quadratic residue a; return smaller of two square roots modulo p. Bounds: p<=97.

split: open-access


prompt:
The exact tonelli shanks square root result violates the stated contract at initial root exponent.

Input [a,p], odd prime p and nonzero quadratic residue a; return smaller of two square roots modulo p. Bounds: p<=97.

split: open-access


prompt:
The exact tonelli shanks square root result violates the stated contract at initial odd component residue.

Input [a,p], odd prime p and nonzero quadratic residue a; return smaller of two square roots modulo p. Bounds: p<=97.

split: open-access


prompt:
The exact tonelli shanks square root result violates the stated contract at order halving correction.

Input [a,p], odd prime p and nonzero quadratic residue a; return smaller of two square roots modulo p. Bounds: p<=97.

split: open-access


prompt:
The exact tonelli shanks square root result violates the stated contract at next subgroup generator.

Input [a,p], odd prime p and nonzero quadratic residue a; return smaller of two square roots modulo p. Bounds: p<=97.

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 struct.unpack(">d",bits.to_bytes(8,"big"))[0] < 0 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 and bits & ((1<<63)-1) else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Decoding derives sign from numerical negativity.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = bits >> 52
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) if not bits >> 63 else 0
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Sign bit contaminates the exponent field.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 53)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits % (1 << 51)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
The hidden leading bit is read from encoded exponent.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = "infinity"
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = "nan" if fraction & (1<<51) else "infinity"
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Nonfinite classification ignores a NaN payload.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & 1) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = True if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
NaN quietness is inferred from payload parity.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = 0 if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
The quiet marker leaks into diagnostic payload.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = "subnormal" if exp == 0 else "normal"
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = "zero" if exp == 0 else "normal"
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Zero decoding conflates zero and subnormal.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else 0
    significand = fraction | (1 << 52) if exp else fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Subnormals receive the normal exponent bias.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

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
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction | (1 << 52)
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 2047
    fraction = bits & ((1 << 52)-1)
    if exp == 2047:
        kind = 'nan' if fraction else 'infinity'
        quiet = bool(fraction & (1 << 51)) if fraction else None
        payload = fraction & ((1 << 51)-1) if fraction else None
        return [sign, kind, None, None, quiet, payload]
    kind = 'zero' if exp == 0 and fraction == 0 else 'subnormal' if exp == 0 else 'normal'
    unbiased = exp-1023 if exp else -1022
    significand = fraction
    return [sign, kind, unbiased, significand, None, None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive zero', solve(0), [1,'zero',-1022,0,None,None])
check('negative zero', solve(1<<63), [-1,'zero',-1022,0,None,None])
check('tiny subnormal', solve(N), [1,'subnormal',-1022,N,None,None])
check('negative subnormal', solve((1<<63)|N), [-1,'subnormal',-1022,N,None,None])
check('normal exact power', solve((1023+N)<<52), [1,'normal',N,1<<52,None,None])
check('normal fraction', solve((1023<<52)|N), [1,'normal',0,(1<<52)|N,None,None])
check('positive infinity', solve(2047<<52), [1,'infinity',None,None,None,None])
check('negative infinity', solve((1<<63)|(2047<<52)), [-1,'infinity',None,None,None,None])
check('quiet payload', solve((2047<<52)|(1<<51)|N), [1,'nan',None,None,True,N])
check('signaling payload', solve((2047<<52)|N), [1,'nan',None,None,False,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:
Subnormals acquire an implicit leading one.

Decode an unsigned 64-bit IEEE binary64 encoding into sign, kind, unbiased exponent, integer significand, quiet flag and payload. Nonfinite fields use null; zero and subnormal exponents are -1022.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) and math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
Stepping checks only destination NaNs.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
Stepping checks only source NaNs.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return xb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return 0 if x == 0 else xb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
An equal-value early return preserves the wrong zero sign.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return xb+1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
Leaving zero increments its old signed encoding.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb-1
    return xb-1 if y>x else xb+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
Positive adjacency always increments the encoding.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb+1 if y>x else xb-1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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(xb, yb):
    x=struct.unpack('>d', xb.to_bytes(8,'big'))[0]
    y=struct.unpack('>d', yb.to_bytes(8,'big'))[0]
    if math.isnan(x) or math.isnan(y):
        return 0x7ff8000000000000
    if x == y:
        return yb
    if x == 0:
        return (yb & (1<<63)) | 1
    if x > 0:
        return xb+1 if y>x else xb-1
    return xb-1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive step', solve(0x3ff0000000000000, 0x4000000000000000), 0x3ff0000000000001)
check('positive reverse', solve(0x3ff0000000000000, 0), 0x3fefffffffffffff)
check('negative forward', solve(0xbff0000000000000, 0), 0xbfefffffffffffff)
check('negative away', solve(0xbff0000000000000, 0xc000000000000000), 0xbff0000000000001)
check('negative zero equality', solve(0, 1<<63), 1<<63)
check('positive zero equality', solve(1<<63, 0), 0)
check('zero negative', solve(0, 0xbff0000000000000), (1<<63)|1)
check('zero positive', solve(1<<63, 0x3ff0000000000000), 1)
check('nan target', solve(0x3ff0000000000000, (0x7ff<<52)|N), 0x7ff8000000000000)
check('nan source', solve((0x7ff<<52)|N, 0), 0x7ff8000000000000)
check('finite step varies', solve((1023+N)<<52, 0), ((1023+N)<<52)-1)
check('infinity inward', solve(0x7ff0000000000000, 0), 0x7fefffffffffffff)
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:
Negative adjacency uses unsigned monotonic order.

Return the binary64 bit pattern one representable step from x toward y, or canonical quiet NaN for NaN operands. Equal operands return the exact bits of y, including zero sign.

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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'infinity'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return '0x0.0p+0'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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:
ULP lookup reports NaN as infinity.

Return a finite binary64 ulp as a hex string; NaN maps to nan and either infinity maps to infinity. For subnormals and zero the ulp is the minimum positive subnormal.

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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '0x1.0000000000000p+971'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'nan'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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:
ULP lookup assigns a finite spacing to infinity.

Return a finite binary64 ulp as a hex string; NaN maps to nan and either infinity maps to infinity. For subnormals and zero the ulp is the minimum positive subnormal.

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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return 0.0.hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x1p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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:
Zero ULP is rounded to zero.

Return a finite binary64 ulp as a hex string; NaN maps to nan and either infinity maps to infinity. For subnormals and zero the ulp is the minimum positive subnormal.

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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-52,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-54,-1074)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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:
ULP uses the exponent of the next binade.

Return a finite binary64 ulp as a hex string; NaN maps to nan and either infinity maps to infinity. For subnormals and zero the ulp is the minimum positive subnormal.

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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=e-53
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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):
    x=struct.unpack('>d',bits.to_bytes(8,'big'))[0]
    if math.isnan(x): return 'nan'
    if math.isinf(x): return 'infinity'
    x=abs(x)
    if x == 0: return float.fromhex('0x0.0000000000001p-1022').hex()
    m,e=math.frexp(x)
    e=max(e-53,-1022)
    return math.ldexp(1.0,e).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero', solve(0), '0x0.0000000000001p-1022')
check('negative zero', solve(1<<63), '0x0.0000000000001p-1022')
check('subnormal', solve(N), '0x0.0000000000001p-1022')
check('power boundary', solve((1023+N)<<52), math.ldexp(1.0,N-52).hex())
check('negative power', solve((1<<63)|((1023+N)<<52)), math.ldexp(1.0,N-52).hex())
check('below power', solve(((1023+N)<<52)-1), math.ldexp(1.0,N-53).hex())
check('infinity', solve(0x7ff0000000000000), 'infinity')
check('nan', solve(0x7ff8000000000000|N), 'nan')
check('maximum', solve(0x7fefffffffffffff), '0x1.0000000000000p+971')
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:
ULP scaling underflows below the subnormal spacing.

Return a finite binary64 ulp as a hex string; NaN maps to nan and either infinity maps to infinity. For subnormals and zero the ulp is the minimum positive subnormal.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r)
    if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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(q,g,r,s,sign,mode):
    inexact=bool(g)
    if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
An inexact result ignores sticky-only residue.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g)
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and (r or s))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
Nearest-even rounding ignores retained parity.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g or r or s)
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool((g or r) and (r or s or q%2))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
Nearest rounding treats any discarded bit as above-half.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and (s or q%2))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and q%2)
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
Nearest rounding loses the round bit after a guard.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and (r or q%2))
    elif mode == 'nearest-away': increment=bool(g)
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
Nearest rounding loses sticky residue after a guard.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
    elif mode == 'nearest-away': increment=bool(g and (r or s or q%2))
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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(q,g,r,s,sign,mode):
    inexact=bool(g or r or s)
    if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
    elif mode == 'nearest-away': increment=bool(g and (r or s))
    elif mode == 'up': increment=sign>0 and inexact
    elif mode == 'down': increment=sign<0 and inexact
    else: increment=False
    value=sign*(q+int(increment))
    return [value,inexact,bool(increment)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,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:
Nearest-away incorrectly follows ties-to-even.

Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.

split: open-access