FAILURE MAP
← Case archive

FA-5361 / Integer arithmetic / Open access

Signed integer bit length · case 01

The minus sign is counted as a binary digit.

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

ROOT CAUSE

The minus sign is counted as a binary digit.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return abs(n).bit_length()

Unsuccessful approach: Removing the sign still treats the zero literal as one significant bit.

Case contract

Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. Return the number of significant binary magnitude digits, with zero requiring zero digits. Exact operational definition: abs(n).bit_length()

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return len(bin(n))-2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (-8,)', solve(*(-8,)), 4)
check('fixture 3: (7,)', solve(*(7,)), 3)
check('fixture 4: (8,)', solve(*(8,)), 4)
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
fixture 1: (0,)10Failed
fixture 2: (-8,)54Failed
fixture 3: (7,)33Passed
fixture 4: (8,)44Passed

SHA-256 / 1d3eb25cf1b8f8e29ac6bdb4f350b7e105c85862d2f75d7cd9666e2e64094b07

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return len(bin(n).lstrip("-"))-2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (-8,)', solve(*(-8,)), 4)
check('fixture 3: (7,)', solve(*(7,)), 3)
check('fixture 4: (8,)', solve(*(8,)), 4)
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
fixture 1: (0,)10Failed
fixture 2: (-8,)44Passed
fixture 3: (7,)33Passed
fixture 4: (8,)44Passed

SHA-256 / 3acf392e65ada304f1259db88cdeb18a5488aea3cf5c4d76eadf5ec442146b30

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n):
    return abs(n).bit_length()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (-8,)', solve(*(-8,)), 4)
check('fixture 3: (7,)', solve(*(7,)), 3)
check('fixture 4: (8,)', solve(*(8,)), 4)
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
fixture 1: (0,)00Passed
fixture 2: (-8,)44Passed
fixture 3: (7,)33Passed
fixture 4: (8,)44Passed

SHA-256 / 181a1a7590f0fb7266bfcfc802ac1bdee947071df79162e5a03298082b2f33e8

Verification & scope

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

Case digest / 83eb4c5f749d5b5af2856e3b092028be6e1c06ba81cbc78a2000c6463663541f