FAILURE MAP
← Case archive

FA-17206 / Floating-point arithmetic / Open access

Cube root canonicalizes negative zero · case 01

Cube root canonicalizes negative zero.

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

ROOT CAUSE

Cube root canonicalizes negative zero. The faulty expression is if x==0: return "0".

VERIFIED REPAIR

Apply the contract at this fault site using if x==0: return render(x).

Unsuccessful approach: The attempted local correction if x==0: return "-0" still violates the explicit regression fixtures.

Case contract

Real cube root on finite binary64 inputs. Split magnitude with frexp, divide exponent by three with floor division, and apply residual exponent before rooting. Return signed zero unchanged. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

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
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x):
    try:
        if x==0: return "0"
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=(math.ldexp(m,r))**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube11Passed
negative cube-1-1Passed
huge1e+1001e+100Passed
tiny1e-1001e-100Passed
power remainder2.51984209982.5198420998Passed
negative zero0-0Failed
positive zero00Passed
subnormal1.703183936e-1081.703183936e-108Passed

SHA-256 / 178020bc73bccda9ed77ae2fcd3495649dc4f6bbe6d70156d020dd85bc112753

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x):
    try:
        if x==0: return "-0"
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=(math.ldexp(m,r))**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube11Passed
negative cube-1-1Passed
huge1e+1001e+100Passed
tiny1e-1001e-100Passed
power remainder2.51984209982.5198420998Passed
negative zero-0-0Passed
positive zero-00Failed
subnormal1.703183936e-1081.703183936e-108Passed

SHA-256 / 56fcbd7fb3d507faf14b1a276bfefa077fd86fb6652417b5abd8940ae8bba584

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(x):
    try:
        if x==0: return render(x)
        m,e=math.frexp(abs(x))
        q,r=divmod(e,3)
        root=(math.ldexp(m,r))**(1/3)
        result=math.ldexp(root,q)
        return render(math.copysign(result,x))
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('integer cube', solve(float(N**3)), render(float(N)))
check('negative cube', solve(-float(N**3)), render(-float(N)))
check('huge', solve(1e300), "1e+100")
check('tiny', solve(1e-300), "1e-100")
check('power remainder', solve(16.0), render(16.0**(1/3)))
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-358)))
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
integer cube11Passed
negative cube-1-1Passed
huge1e+1001e+100Passed
tiny1e-1001e-100Passed
power remainder2.51984209982.5198420998Passed
negative zero-0-0Passed
positive zero00Passed
subnormal1.703183936e-1081.703183936e-108Passed

SHA-256 / 8d1682424e4547465621b0843c39f37c1b286e588de48c5a99019c32d45b41d1

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:44.050842+00:00.

Case digest / a1badc8df3654aa853311caba209dfe86d243486691e85c0368dc32f7fa17a0c