FA-331 / Integer arithmetic / Open access
Rescaling integer ticks loses precision in an intermediate step · case 01
Large counters change by several ticks after a float conversion, or fractional source units disappear before multiplication.
ROOT CAUSE
The scale conversion rounds an intermediate value rather than performing one exact rational conversion at the end.
VERIFIED REPAIR
Multiply the integer tick count by the target rate before exact floor division by the source rate.
Unsuccessful approach: Dividing first avoids a large intermediate product but discards source-unit remainders that contribute whole target ticks.
Case contract
For integer ticks, positive integer source_rate, and nonnegative integer target_rate, return floor(ticks * target_rate / source_rate) exactly. Invalid rates return None. Python arbitrary-size integers are part of this model.
Why this case matters
Audio, video, and instrumentation timelines are often expressed as integer ticks at different rates. Both float conversion and premature integer division can break rescaling invariants.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(ticks, source_rate, target_rate):
if source_rate <= 0 or target_rate < 0:
return None
return int(ticks / source_rate * target_rate)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large identity conversion keeps low bits', solve(2 ** 60 + N, 1, 1), 2 ** 60 + N)
check('subunit source amount becomes whole target ticks', solve(N, N + 1, 2 * (N + 1)), 2 * N)
check('negative fractional result floors downward', solve(-1, N + 1, N), -1)
check('exact integral rescaling', solve(3 * N, 3, 7), 7 * N)
check('zero tick count', solve(0, N, 3), 0)
check('zero target rate', solve(2 ** 60 + N, N, 0), 0)
check('zero source rate rejected', solve(N, 0, 1), None)
check('negative target rate rejected', solve(N, 1, -1), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large identity conversion keeps low bits | 1152921504606846976 | 1152921504606846977 | Failed |
| subunit source amount becomes whole target ticks | 2 | 2 | Passed |
| negative fractional result floors downward | 0 | -1 | Failed |
| exact integral rescaling | 7 | 7 | Passed |
| zero tick count | 0 | 0 | Passed |
| zero target rate | 0 | 0 | Passed |
| zero source rate rejected | None | None | Passed |
| negative target rate rejected | None | None | Passed |
SHA-256 / dd28042b2574affdc39a2e078c175335acdba799aacfa44feb555eb07e89c7fc
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(ticks, source_rate, target_rate):
if source_rate <= 0 or target_rate < 0:
return None
return (ticks // source_rate) * target_rate
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large identity conversion keeps low bits', solve(2 ** 60 + N, 1, 1), 2 ** 60 + N)
check('subunit source amount becomes whole target ticks', solve(N, N + 1, 2 * (N + 1)), 2 * N)
check('negative fractional result floors downward', solve(-1, N + 1, N), -1)
check('exact integral rescaling', solve(3 * N, 3, 7), 7 * N)
check('zero tick count', solve(0, N, 3), 0)
check('zero target rate', solve(2 ** 60 + N, N, 0), 0)
check('zero source rate rejected', solve(N, 0, 1), None)
check('negative target rate rejected', solve(N, 1, -1), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large identity conversion keeps low bits | 1152921504606846977 | 1152921504606846977 | Passed |
| subunit source amount becomes whole target ticks | 0 | 2 | Failed |
| negative fractional result floors downward | -1 | -1 | Passed |
| exact integral rescaling | 7 | 7 | Passed |
| zero tick count | 0 | 0 | Passed |
| zero target rate | 0 | 0 | Passed |
| zero source rate rejected | None | None | Passed |
| negative target rate rejected | None | None | Passed |
SHA-256 / 54d86fef68f79d155c9ae463a42a1159d293a66f24b494c9a7e0e1c4c1333b4a
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(ticks, source_rate, target_rate):
if source_rate <= 0 or target_rate < 0:
return None
return (ticks * target_rate) // source_rate
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large identity conversion keeps low bits', solve(2 ** 60 + N, 1, 1), 2 ** 60 + N)
check('subunit source amount becomes whole target ticks', solve(N, N + 1, 2 * (N + 1)), 2 * N)
check('negative fractional result floors downward', solve(-1, N + 1, N), -1)
check('exact integral rescaling', solve(3 * N, 3, 7), 7 * N)
check('zero tick count', solve(0, N, 3), 0)
check('zero target rate', solve(2 ** 60 + N, N, 0), 0)
check('zero source rate rejected', solve(N, 0, 1), None)
check('negative target rate rejected', solve(N, 1, -1), None)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| large identity conversion keeps low bits | 1152921504606846977 | 1152921504606846977 | Passed |
| subunit source amount becomes whole target ticks | 2 | 2 | Passed |
| negative fractional result floors downward | -1 | -1 | Passed |
| exact integral rescaling | 7 | 7 | Passed |
| zero tick count | 0 | 0 | Passed |
| zero target rate | 0 | 0 | Passed |
| zero source rate rejected | None | None | Passed |
| negative target rate rejected | None | None | Passed |
SHA-256 / 7f45b22f6196f3ba9c8581699ba2a493e0ca0b0eb4910b7e7d98edd698a2fb7d
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:36:52.106401+00:00.
Case digest / 7814161f639941fe2a05a31a2bc5ed21192b18a4e912890cc8b0f0e027cfe297