FAILURE MAP
← Case archive

FA-78741 / Broadcast timecode arithmetic / Open access

Decimal seconds to frame label: exact decimal parse · case 01

An offset of 0.06 s at 25 fps lands on frame 1 instead of frame 2.

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

ROOT CAUSE

The decimal string is parsed through a binary float, falling just below exact half frames.

VERIFIED REPAIR

Parse the decimal text directly into an exact fraction.

Unsuccessful approach: Rounding the float to three decimals still yields a binary approximation.

Case contract

Convert a decimal seconds string exactly (no binary floating point) at rate [N,D] to the nearest frame, halves rounding up, and a non-drop label using the nominal rate ceil(N/D). Negative input returns None.

Why this case matters

Timecode arithmetic errors misplace edits, commercial breaks and captions against the broadcast clock.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(float(sec))
    if x<0:
        return None
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['1.5', [25, 1]], [38, '00:00:01:13'])], [('regression: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('regression variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair probe: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [50, 1]], None)], [('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.14', [25, 1]], [4, '00:00:00:04'])]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
regression: exact decimal parse[1, '00:00:00:01'][2, '00:00:00:02']Failed
regression variant: exact decimal parse[182, '00:00:07:07'][183, '00:00:07:08']Failed
partial repair probe: exact decimal parse[0, '00:00:00:00'][0, '00:00:00:00']Passed
partial repair variant: exact decimal parse[4, '00:00:00:04'][5, '00:00:00:05']Failed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[30, '00:00:01:00'][30, '00:00:01:00']Passed
normal controlNoneNonePassed
normal control[296, '00:00:12:08'][296, '00:00:12:08']Passed

SHA-256 / 83a82a0790f9ffdb27996414e48cf9fb4d289a2101c58c5e7d93d9b8a96b835d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(round(float(sec),3))
    if x<0:
        return None
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['1.5', [25, 1]], [38, '00:00:01:13'])], [('regression: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('regression variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair probe: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [50, 1]], None)], [('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.14', [25, 1]], [4, '00:00:00:04'])]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
regression: exact decimal parse[1, '00:00:00:01'][2, '00:00:00:02']Failed
regression variant: exact decimal parse[182, '00:00:07:07'][183, '00:00:07:08']Failed
partial repair probe: exact decimal parse[1, '00:00:00:01'][0, '00:00:00:00']Failed
partial repair variant: exact decimal parse[4, '00:00:00:04'][5, '00:00:00:05']Failed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[30, '00:00:01:00'][30, '00:00:01:00']Passed
normal controlNoneNonePassed
normal control[296, '00:00:12:08'][296, '00:00:12:08']Passed

SHA-256 / 56db0ceca61b87d3db818c076c79826052f5f3c41a8368362c1e6e432dd79924

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
    num,den=fps
    x=Fraction(sec)
    if x<0:
        return None
    n=x*num/den
    fr=math.floor(n+Fraction(1,2))
    nominal=-(-num//den)
    return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['-1', [24000, 1001]], None), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('partial repair variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [25, 1]], None), ('normal control', ['1.5', [25, 1]], [38, '00:00:01:13'])], [('regression: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('regression variant: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair probe: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.18', [50, 1]], [9, '00:00:00:09']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['-0.5', [50, 1]], None)], [('regression: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('regression variant: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair probe: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['-1', [25, 1]], None), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['1.5', [24, 1]], [36, '00:00:01:12']), ('normal control', ['3600', [24, 1]], [86400, '01:00:00:00'])], [('regression: exact decimal parse', ['0.18', [25, 1]], [5, '00:00:00:05']), ('regression variant: exact decimal parse', ['0.06', [25, 1]], [2, '00:00:00:02']), ('partial repair probe: exact decimal parse', ['7.3', [25, 1]], [183, '00:00:07:08']), ('partial repair variant: exact decimal parse', ['0.0166', [30000, 1001]], [0, '00:00:00:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.06', [24000, 1001]], [1, '00:00:00:01']), ('normal control', ['0.14', [25, 1]], [4, '00:00:00:04'])]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
regression: exact decimal parse[2, '00:00:00:02'][2, '00:00:00:02']Passed
regression variant: exact decimal parse[183, '00:00:07:08'][183, '00:00:07:08']Passed
partial repair probe: exact decimal parse[0, '00:00:00:00'][0, '00:00:00:00']Passed
partial repair variant: exact decimal parse[5, '00:00:00:05'][5, '00:00:00:05']Passed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[30, '00:00:01:00'][30, '00:00:01:00']Passed
normal controlNoneNonePassed
normal control[296, '00:00:12:08'][296, '00:00:12:08']Passed

SHA-256 / fdb1ed9d8848a65ec5b7068cd5923aac82480cf365228909834b795891791805

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to SMPTE or any broadcast standard. 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:49:38.019524+00:00.

Case digest / 32e8775a4a6af34c4b2aab581eb87ae9bbaa1517b48ef40c053a16d3190636c8