FAILURE MAP
← Case archive

FA-5391 / Integer arithmetic / Open access

Unsigned rotate right · case 01

Right shifting discards the outgoing low bits.

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

ROOT CAUSE

Right shifting discards the outgoing low bits.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return ((n >> (k%bits)) | (n << ((bits-k)%bits))) & ((1<<bits)-1)

Unsuccessful approach: Left shifting by the same offset places wrap bits incorrectly.

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. n is an unsigned word and k is nonnegative; rotate by k modulo bits. Exact operational definition: ((n >> (k%bits)) | (n << ((bits-k)%bits))) & ((1<<bits)-1)

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, k, bits):
    return n >> k
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 8)', solve(*(3, 1, 8)), 129)
check('fixture 2: (12, 2, 8)', solve(*(12, 2, 8)), 3)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
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: (3, 1, 8)1129Failed
fixture 2: (12, 2, 8)33Passed
fixture 3: (128, 8, 8)0128Failed
fixture 4: (15, 0, 8)1515Passed

SHA-256 / 2e677a414c8014f81d5940917ec949c5638d25576efacce4bd585832fbdb8012

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, k, bits):
    return ((n >> k) | (n << k)) & ((1<<bits)-1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 8)', solve(*(3, 1, 8)), 129)
check('fixture 2: (12, 2, 8)', solve(*(12, 2, 8)), 3)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
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: (3, 1, 8)7129Failed
fixture 2: (12, 2, 8)513Failed
fixture 3: (128, 8, 8)0128Failed
fixture 4: (15, 0, 8)1515Passed

SHA-256 / 2e041b8f7318d4b9d8b7ea4caa92d6de7c7c5e31b0d1d4dba7076b625e64df01

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, k, bits):
    return ((n >> (k%bits)) | (n << ((bits-k)%bits))) & ((1<<bits)-1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 8)', solve(*(3, 1, 8)), 129)
check('fixture 2: (12, 2, 8)', solve(*(12, 2, 8)), 3)
check('fixture 3: (128, 8, 8)', solve(*(128, 8, 8)), 128)
check('fixture 4: (15, 0, 8)', solve(*(15, 0, 8)), 15)
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: (3, 1, 8)129129Passed
fixture 2: (12, 2, 8)33Passed
fixture 3: (128, 8, 8)128128Passed
fixture 4: (15, 0, 8)1515Passed

SHA-256 / fd70d8542d3c63de570641053984b6b1cd0b3005c4e1353fb876acf9691090c2

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

Case digest / 2af7c80592f42ce1357100365e842898605130c88da4433240d5fcea02a1e630