FAILURE MAP
← Case archive

FA-5431 / Integer arithmetic / Open access

Midpoint floor no float · case 01

The floating midpoint loses integer precision and negative floor semantics.

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

ROOT CAUSE

The floating midpoint loses integer precision and negative floor semantics.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return (a+b)//2

Unsuccessful approach: A direction-dependent correction truncates reversed odd spans.

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. a and b may be signed and unordered; return floor((a+b)/2) exactly. Exact operational definition: (a+b)//2

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(a, b):
    return int((a+b)/2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1152921504606846976, 1152921504606846978)', solve(*(1152921504606846976, 1152921504606846978)), 1152921504606846977)
check('fixture 2: (-2, -1)', solve(*(-2, -1)), -2)
check('fixture 3: (0, 3)', solve(*(0, 3)), 1)
check('fixture 4: (3, 0)', solve(*(3, 0)), 1)
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: (1152921504606846976, 1152921504606846978)11529215046068469761152921504606846977Failed
fixture 2: (-2, -1)-1-2Failed
fixture 3: (0, 3)11Passed
fixture 4: (3, 0)11Passed

SHA-256 / fc391f84255103992bd5b6dffe3ad3ea4b01d37cead60b27a3e59fdef1911a77

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(a, b):
    return a+(b-a)//2 if a <= b else a-(a-b)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1152921504606846976, 1152921504606846978)', solve(*(1152921504606846976, 1152921504606846978)), 1152921504606846977)
check('fixture 2: (-2, -1)', solve(*(-2, -1)), -2)
check('fixture 3: (0, 3)', solve(*(0, 3)), 1)
check('fixture 4: (3, 0)', solve(*(3, 0)), 1)
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: (1152921504606846976, 1152921504606846978)11529215046068469771152921504606846977Passed
fixture 2: (-2, -1)-2-2Passed
fixture 3: (0, 3)11Passed
fixture 4: (3, 0)21Failed

SHA-256 / b0e463a864a0822a4adb46b7663fca4ccf622ac2928ba58c9529702593a89d36

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(a, b):
    return (a+b)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1152921504606846976, 1152921504606846978)', solve(*(1152921504606846976, 1152921504606846978)), 1152921504606846977)
check('fixture 2: (-2, -1)', solve(*(-2, -1)), -2)
check('fixture 3: (0, 3)', solve(*(0, 3)), 1)
check('fixture 4: (3, 0)', solve(*(3, 0)), 1)
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: (1152921504606846976, 1152921504606846978)11529215046068469771152921504606846977Passed
fixture 2: (-2, -1)-2-2Passed
fixture 3: (0, 3)11Passed
fixture 4: (3, 0)11Passed

SHA-256 / b414e44d4909d8c1dd6aa29cc927ed25f60c86448bd6825edc1de4ed0f19c9b1

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

Case digest / 5e135840885a14c1dfd06b97d8b813eb170aecfba3d3ae2c381fa9fc618b48e8