FA-16626 / Floating-point arithmetic / Open access
Exact ratio conversion returns a zero denominator for zero · case 01
Exact ratio conversion returns a zero denominator for zero.
ROOT CAUSE
Exact ratio conversion returns a zero denominator for zero. The faulty expression is if mantissa==0: return [0,0].
VERIFIED REPAIR
Apply the contract at this fault site using if mantissa==0: return [0,1].
Unsuccessful approach: The attempted local correction if mantissa==0: return [sign,1] still violates the explicit regression fixtures.
Case contract
Decode a finite binary64 value into its exact reduced signed numerator and positive power-of-two denominator, using (0,1) for either zero. Infinity and NaN return null.
Why this case matters
An offline floating representation model isolates a reproducible arithmetic fault.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
sign=-1 if bits>>63 else 1
e=(bits>>52)&2047
f=bits&((1<<52)-1)
if e==2047: return None
if e:
mantissa=f|(1<<52)
power=e-1023-52
else:
mantissa=f
power=-1074
if mantissa==0: return [0,0]
while power<0 and mantissa%2==0:
mantissa//=2
power+=1
if power>=0: return [sign*(mantissa<<power),1]
return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large integer | [2305843009213693952, 1] | [2305843009213693952, 1] | Passed |
| positive integer | [2, 1] | [2, 1] | Passed |
| negative integer | [-2, 1] | [-2, 1] | Passed |
| fraction | [1, 2] | [1, 2] | Passed |
| nontrivial fraction | [3, 4] | [3, 4] | Passed |
| minimum subnormal | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| negative subnormal | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| zero | [0, 0] | [0, 1] | Failed |
| negative zero | [0, 0] | [0, 1] | Failed |
| infinity | None | None | Passed |
| nan | None | None | Passed |
SHA-256 / b47ff251ca176b094f9eaa1d75a37e3f3a0ae06cf3f36af4a1c55b491b9c2b70
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
sign=-1 if bits>>63 else 1
e=(bits>>52)&2047
f=bits&((1<<52)-1)
if e==2047: return None
if e:
mantissa=f|(1<<52)
power=e-1023-52
else:
mantissa=f
power=-1074
if mantissa==0: return [sign,1]
while power<0 and mantissa%2==0:
mantissa//=2
power+=1
if power>=0: return [sign*(mantissa<<power),1]
return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large integer | [2305843009213693952, 1] | [2305843009213693952, 1] | Passed |
| positive integer | [2, 1] | [2, 1] | Passed |
| negative integer | [-2, 1] | [-2, 1] | Passed |
| fraction | [1, 2] | [1, 2] | Passed |
| nontrivial fraction | [3, 4] | [3, 4] | Passed |
| minimum subnormal | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| negative subnormal | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| zero | [1, 1] | [0, 1] | Failed |
| negative zero | [-1, 1] | [0, 1] | Failed |
| infinity | None | None | Passed |
| nan | None | None | Passed |
SHA-256 / 90ee0b5f5905d32422b9b4e87b7e8a8bb045ec5f454b953fd913a546094c446b
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(bits):
sign=-1 if bits>>63 else 1
e=(bits>>52)&2047
f=bits&((1<<52)-1)
if e==2047: return None
if e:
mantissa=f|(1<<52)
power=e-1023-52
else:
mantissa=f
power=-1074
if mantissa==0: return [0,1]
while power<0 and mantissa%2==0:
mantissa//=2
power+=1
if power>=0: return [sign*(mantissa<<power),1]
return [sign*mantissa,1<<(-power)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large integer', solve((1023+60+N)<<52), [1<<(60+N),1])
check('positive integer', solve((1023+N)<<52), [1<<N,1])
check('negative integer', solve((1<<63)|((1023+N)<<52)), [-(1<<N),1])
check('fraction', solve(0x3fe0000000000000), [1,2])
check('nontrivial fraction', solve(0x3fe8000000000000), [3,4])
check('minimum subnormal', solve(N), list(math.ldexp(float(N),-1074).as_integer_ratio()))
check('negative subnormal', solve((1<<63)|N), list((-math.ldexp(float(N),-1074)).as_integer_ratio()))
check('zero', solve(0), [0,1])
check('negative zero', solve(1<<63), [0,1])
check('infinity', solve(0x7ff0000000000000), None)
check('nan', solve(0x7ff8000000000000|N), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large integer | [2305843009213693952, 1] | [2305843009213693952, 1] | Passed |
| positive integer | [2, 1] | [2, 1] | Passed |
| negative integer | [-2, 1] | [-2, 1] | Passed |
| fraction | [1, 2] | [1, 2] | Passed |
| nontrivial fraction | [3, 4] | [3, 4] | Passed |
| minimum subnormal | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| negative subnormal | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | [-1, 202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784] | Passed |
| zero | [0, 1] | [0, 1] | Passed |
| negative zero | [0, 1] | [0, 1] | Passed |
| infinity | None | None | Passed |
| nan | None | None | Passed |
SHA-256 / 232c5cccac878943ca1770bff8d7a21afb5af3860d3181aefa1b46f6590a6293
Verification & scope
Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:39:38.035604+00:00.
Case digest / 5819e7c250379bb3cae062744d2a51325b2208128fec00e47f5ffa173d493792