FAILURE MAP
← Case archive

FA-16046 / Floating-point arithmetic / Open access

Exponent adjustment canonicalizes negative zero · case 01

Exponent adjustment canonicalizes negative zero.

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

ROOT CAUSE

Exponent adjustment canonicalizes negative zero. The faulty expression is if x == 0.0: return 0.0.hex().

THE FAILURE

Exponent adjustment canonicalizes negative zero. The faulty expression is if x == 0.0: return 0.0.hex().

Unsuccessful approach: The attempted local correction if x == 0.0: return (-0.0).hex() 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 0.0.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 fixtureActualExpectedOutcome
scale up0x1.8000000000000p+10x1.8000000000000p+1Passed
scale down-0x1.8000000000000p-1-0x1.8000000000000p-1Passed
negative zero0x0.0p+0-0x0.0p+0Failed
positive zero0x0.0p+00x0.0p+0Passed
subnormal input0x0.0000000000002p-10220x0.0000000000002p-1022Passed
subnormal output0x0.8000000000000p-10220x0.8000000000000p-1022Passed
max finite shift zero0x1.fffffffffffffp+10230x1.fffffffffffffp+1023Passed
positive overflow+overflow+overflowPassed
negative overflow-overflow-overflowPassed
negative underflow-0x0.0p+0-0x0.0p+0Passed

SHA-256 / 1de6486e51ec674313d779058eb64e9be7c34a6cfa261e598327b0b1c832a072

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 (-0.0).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 fixtureActualExpectedOutcome
scale up0x1.8000000000000p+10x1.8000000000000p+1Passed
scale down-0x1.8000000000000p-1-0x1.8000000000000p-1Passed
negative zero-0x0.0p+0-0x0.0p+0Passed
positive zero-0x0.0p+00x0.0p+0Failed
subnormal input0x0.0000000000002p-10220x0.0000000000002p-1022Passed
subnormal output0x0.8000000000000p-10220x0.8000000000000p-1022Passed
max finite shift zero0x1.fffffffffffffp+10230x1.fffffffffffffp+1023Passed
positive overflow+overflow+overflowPassed
negative overflow-overflow-overflowPassed
negative underflow-0x0.0p+0-0x0.0p+0Passed

SHA-256 / 1f4ec78cb0bc5890e513c9baa4e6d736ba62229d46c14cc76947508fdcb3320a

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:39:32.778300+00:00.

Case digest / d978a98d2e24179938972f29c3771950444d413e58a6b839029db2e7b3464df6