FA-16056 / Floating-point arithmetic / Open access
Exponent adjustment discards the mantissa sign · case 01
Exponent adjustment discards the mantissa sign.
ROOT CAUSE
Exponent adjustment discards the mantissa sign. The faulty expression is m,e=math.frexp(abs(x)).
VERIFIED REPAIR
Apply the contract at this fault site using m,e=math.frexp(x).
Unsuccessful approach: The attempted local correction m,e=math.frexp(-abs(x)) still violates the explicit regression fixtures.
Case contract
Recompose finite binary64 x after changing its exponent by integer shift. Return hex value, or signed overflow marker. Scaling preserves negative zero and gradual underflow. Inputs exclude NaN and infinity.
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(x, shift):
if x == 0.0: return x.hex()
m,e=math.frexp(abs(x))
target=e+shift
if target>1024: return '-overflow' if x<0 else '+overflow'
try:
result=math.ldexp(m,target)
except OverflowError:
return '-overflow' if x<0 else '+overflow'
return result.hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scale up', solve(1.5,N), math.ldexp(1.5,N).hex())
check('scale down', solve(-1.5,-N), math.ldexp(-1.5,-N).hex())
check('negative zero', solve(-0.0,N), '-0x0.0p+0')
check('positive zero', solve(0.0,-N), '0x0.0p+0')
check('subnormal input', solve(float.fromhex("0x0.0000000000001p-1022"),N), math.ldexp(1.0,N-1074).hex())
check('subnormal output', solve(float.fromhex("0x1p-1022"),-N), math.ldexp(1.0,-1022-N).hex())
check('max finite shift zero', solve(float.fromhex("0x1.fffffffffffffp+1023"),0), '0x1.fffffffffffffp+1023')
check('positive overflow', solve(float.fromhex("0x1p+1023"),N), '+overflow')
check('negative overflow', solve(-float.fromhex("0x1p+1023"),N), '-overflow')
check('negative underflow', solve(-float.fromhex("0x0.0000000000001p-1022"),-N), '-0x0.0p+0')
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 |
|---|---|---|---|
| scale up | 0x1.8000000000000p+1 | 0x1.8000000000000p+1 | Passed |
| scale down | 0x1.8000000000000p-1 | -0x1.8000000000000p-1 | Failed |
| negative zero | -0x0.0p+0 | -0x0.0p+0 | Passed |
| positive zero | 0x0.0p+0 | 0x0.0p+0 | Passed |
| subnormal input | 0x0.0000000000002p-1022 | 0x0.0000000000002p-1022 | Passed |
| subnormal output | 0x0.8000000000000p-1022 | 0x0.8000000000000p-1022 | Passed |
| max finite shift zero | 0x1.fffffffffffffp+1023 | 0x1.fffffffffffffp+1023 | Passed |
| positive overflow | +overflow | +overflow | Passed |
| negative overflow | -overflow | -overflow | Passed |
| negative underflow | 0x0.0p+0 | -0x0.0p+0 | Failed |
SHA-256 / b00a4c4ddcbfc34bad76a1c6e5a96c16f2ea174ff028ee6453cb16ec4e25aa75
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(x, shift):
if x == 0.0: return x.hex()
m,e=math.frexp(-abs(x))
target=e+shift
if target>1024: return '-overflow' if x<0 else '+overflow'
try:
result=math.ldexp(m,target)
except OverflowError:
return '-overflow' if x<0 else '+overflow'
return result.hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scale up', solve(1.5,N), math.ldexp(1.5,N).hex())
check('scale down', solve(-1.5,-N), math.ldexp(-1.5,-N).hex())
check('negative zero', solve(-0.0,N), '-0x0.0p+0')
check('positive zero', solve(0.0,-N), '0x0.0p+0')
check('subnormal input', solve(float.fromhex("0x0.0000000000001p-1022"),N), math.ldexp(1.0,N-1074).hex())
check('subnormal output', solve(float.fromhex("0x1p-1022"),-N), math.ldexp(1.0,-1022-N).hex())
check('max finite shift zero', solve(float.fromhex("0x1.fffffffffffffp+1023"),0), '0x1.fffffffffffffp+1023')
check('positive overflow', solve(float.fromhex("0x1p+1023"),N), '+overflow')
check('negative overflow', solve(-float.fromhex("0x1p+1023"),N), '-overflow')
check('negative underflow', solve(-float.fromhex("0x0.0000000000001p-1022"),-N), '-0x0.0p+0')
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 |
|---|---|---|---|
| scale up | -0x1.8000000000000p+1 | 0x1.8000000000000p+1 | Failed |
| scale down | -0x1.8000000000000p-1 | -0x1.8000000000000p-1 | Passed |
| negative zero | -0x0.0p+0 | -0x0.0p+0 | Passed |
| positive zero | 0x0.0p+0 | 0x0.0p+0 | Passed |
| subnormal input | -0x0.0000000000002p-1022 | 0x0.0000000000002p-1022 | Failed |
| subnormal output | -0x0.8000000000000p-1022 | 0x0.8000000000000p-1022 | Failed |
| max finite shift zero | -0x1.fffffffffffffp+1023 | 0x1.fffffffffffffp+1023 | Failed |
| positive overflow | +overflow | +overflow | Passed |
| negative overflow | -overflow | -overflow | Passed |
| negative underflow | -0x0.0p+0 | -0x0.0p+0 | Passed |
SHA-256 / c3dd75a90180b89f6ba6fd5011f7bf8854caef080fd4c9ed5c3f5048b313d3b8
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(x, shift):
if x == 0.0: return x.hex()
m,e=math.frexp(x)
target=e+shift
if target>1024: return '-overflow' if x<0 else '+overflow'
try:
result=math.ldexp(m,target)
except OverflowError:
return '-overflow' if x<0 else '+overflow'
return result.hex()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scale up', solve(1.5,N), math.ldexp(1.5,N).hex())
check('scale down', solve(-1.5,-N), math.ldexp(-1.5,-N).hex())
check('negative zero', solve(-0.0,N), '-0x0.0p+0')
check('positive zero', solve(0.0,-N), '0x0.0p+0')
check('subnormal input', solve(float.fromhex("0x0.0000000000001p-1022"),N), math.ldexp(1.0,N-1074).hex())
check('subnormal output', solve(float.fromhex("0x1p-1022"),-N), math.ldexp(1.0,-1022-N).hex())
check('max finite shift zero', solve(float.fromhex("0x1.fffffffffffffp+1023"),0), '0x1.fffffffffffffp+1023')
check('positive overflow', solve(float.fromhex("0x1p+1023"),N), '+overflow')
check('negative overflow', solve(-float.fromhex("0x1p+1023"),N), '-overflow')
check('negative underflow', solve(-float.fromhex("0x0.0000000000001p-1022"),-N), '-0x0.0p+0')
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 |
|---|---|---|---|
| scale up | 0x1.8000000000000p+1 | 0x1.8000000000000p+1 | Passed |
| scale down | -0x1.8000000000000p-1 | -0x1.8000000000000p-1 | Passed |
| negative zero | -0x0.0p+0 | -0x0.0p+0 | Passed |
| positive zero | 0x0.0p+0 | 0x0.0p+0 | Passed |
| subnormal input | 0x0.0000000000002p-1022 | 0x0.0000000000002p-1022 | Passed |
| subnormal output | 0x0.8000000000000p-1022 | 0x0.8000000000000p-1022 | Passed |
| max finite shift zero | 0x1.fffffffffffffp+1023 | 0x1.fffffffffffffp+1023 | Passed |
| positive overflow | +overflow | +overflow | Passed |
| negative overflow | -overflow | -overflow | Passed |
| negative underflow | -0x0.0p+0 | -0x0.0p+0 | Passed |
SHA-256 / 7e4c33c61df5712b8d12f73a8dd7e65f00dde45b83052690218cd8290e26865d
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:32.735201+00:00.
Case digest / 1ac7dbdbc6fa61d7d2fe30ff3aa2d209920cc1e881a0aeee1fe173ee8efebef3