FAILURE MAP
← Case archive

FA-15051 / Numerics / Open access

Negative radix encoding: negative base carry · case 01

The exact negative radix encoding result violates the stated contract at negative base carry.

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

ROOT CAUSE

The negative base carry step uses (n-r)//b instead of (n-r)//(-b).

THE FAILURE

The negative base carry step uses (n-r)//b instead of (n-r)//(-b).

Unsuccessful approach: The partial repair n//(-b) still violates the negative base carry invariant.

Case contract

Input [integer, magnitude base>=2]; return most-significant-first digits 0..base-1 representing integer in radix -base. Bounds: |integer|<=100 and base<=8.

Why this case matters

Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    n,b=x
    if n==0:return [0]
    out=[]
    for _ in range(60):
     if n==0:break
     r=n%b
     out.append(r)
     n=(n-r)//b
    return out[::-1] if bool(out) else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 4], [2, 2, 1, 0]), ([-100, 5], [1, 1, 0, 0]), ([-100, 6], [1, 4, 5, 2]), ([-100, 7], [1, 5, 1, 5]), ([-100, 8], [1, 7, 5, 4])], [([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 5], [1, 1, 0, 0]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-98, 5], [1, 1, 0, 2]), ([-98, 6], [1, 4, 5, 4]), ([-98, 7], [1, 5, 0, 0]), ([-98, 8], [1, 7, 5, 6])], [([-100, 4], [2, 2, 1, 0]), ([-100, 8], [1, 7, 5, 4]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-96, 8], [1, 7, 4, 0]), ([-95, 2], [1, 1, 1, 0, 0, 0, 0, 1]), ([-95, 3], [1, 2, 1, 2, 2, 1]), ([-95, 4], [2, 2, 0, 1])], [([-100, 5], [1, 1, 0, 0]), ([-99, 4], [2, 2, 1, 1]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-93, 4], [2, 2, 0, 3]), ([-93, 5], [1, 2, 4, 2]), ([-93, 6], [1, 4, 4, 3]), ([-93, 7], [1, 5, 0, 5])], [([-100, 6], [1, 4, 5, 2]), ([-99, 7], [1, 5, 1, 6]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-91, 7], [1, 6, 6, 0]), ([-91, 8], [1, 7, 4, 5]), ([-90, 2], [1, 1, 1, 1, 1, 0, 1, 0]), ([-90, 3], [1, 2, 1, 2, 0, 0])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, solve(args), expected)
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
explicit oracle 0[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0][1, 1, 1, 0, 1, 1, 0, 0]Failed
explicit oracle 1[1, 4, 4][2, 4, 4]Failed
explicit oracle 2[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 0, 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4][1, 7, 5, 4]Failed

SHA-256 / 9e43fd40dc8acd084220a202c8fe938d7fde29c5d6c64b9ef1d5fe60762c668e

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    n,b=x
    if n==0:return [0]
    out=[]
    for _ in range(60):
     if n==0:break
     r=n%b
     out.append(r)
     n=n//(-b)
    return out[::-1] if bool(out) else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 4], [2, 2, 1, 0]), ([-100, 5], [1, 1, 0, 0]), ([-100, 6], [1, 4, 5, 2]), ([-100, 7], [1, 5, 1, 5]), ([-100, 8], [1, 7, 5, 4])], [([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 5], [1, 1, 0, 0]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-98, 5], [1, 1, 0, 2]), ([-98, 6], [1, 4, 5, 4]), ([-98, 7], [1, 5, 0, 0]), ([-98, 8], [1, 7, 5, 6])], [([-100, 4], [2, 2, 1, 0]), ([-100, 8], [1, 7, 5, 4]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-96, 8], [1, 7, 4, 0]), ([-95, 2], [1, 1, 1, 0, 0, 0, 0, 1]), ([-95, 3], [1, 2, 1, 2, 2, 1]), ([-95, 4], [2, 2, 0, 1])], [([-100, 5], [1, 1, 0, 0]), ([-99, 4], [2, 2, 1, 1]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-93, 4], [2, 2, 0, 3]), ([-93, 5], [1, 2, 4, 2]), ([-93, 6], [1, 4, 4, 3]), ([-93, 7], [1, 5, 0, 5])], [([-100, 6], [1, 4, 5, 2]), ([-99, 7], [1, 5, 1, 6]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-91, 7], [1, 6, 6, 0]), ([-91, 8], [1, 7, 4, 5]), ([-90, 2], [1, 1, 1, 1, 1, 0, 1, 0]), ([-90, 3], [1, 2, 1, 2, 0, 0])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, solve(args), expected)
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
explicit oracle 0[1, 1, 0, 1, 0, 0, 1, 0, 0][1, 1, 1, 0, 1, 1, 0, 0]Failed
explicit oracle 1[7, 1, 3, 4][2, 4, 4]Failed
explicit oracle 2[2, 0, 1, 0, 2][1, 2, 1, 1, 1, 2]Failed
explicit oracle 3[3, 1, 1, 1, 0][2, 2, 1, 0]Failed
explicit oracle 4[1, 0, 0][1, 1, 0, 0]Failed
explicit oracle 5[3, 4, 2][1, 4, 5, 2]Failed
explicit oracle 6[5, 0, 5][1, 5, 1, 5]Failed
explicit oracle 7[6, 4, 4][1, 7, 5, 4]Failed

SHA-256 / 48e212294f24a1b3ff518d4f2f8ca0ab37055622b38985e4e68ee612f1638858

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 8 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

A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. 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:22.965239+00:00.

Case digest / 87215864897fdc3577a319238de11ab183c840a91095df0c8854e15816461eae