FAILURE MAP
← Case archive

FA-61931 / Currency rounding and FX conversion / Open access

Legacy pairs use a derived direct cross rate instead of triangulating · case 01

Mark to franc conversions disagree with the triangulated reference amount.

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

ROOT CAUSE

A cross rate rate[to]/rate[frm] rounded to six decimals replaces the two-leg EUR computation.

VERIFIED REPAIR

Convert through a three-decimal EUR intermediate using only the fixed EUR rates.

Unsuccessful approach: Using the unrounded cross rate still skips the mandatory intermediate rounding.

Case contract

solve(amount, frm, to): stipulated legacy-currency triangulation. Fixed rates are units per 1 EUR (DEM 1.95583, FRF 6.55957, ITL 1936.27, ESP 166.386, IEP 0.787564, NLG 2.20371, BEF 40.3399, PTE 200.482, ATS 13.7603, FIM 5.94573). Exponents: ITL, ESP, BEF, PTE 0; others and EUR 2. Legacy to legacy: divide by the source rate, round the EUR intermediate half-up to 3 decimals, multiply by the target rate, round half-up to the target exponent. Legacy to EUR: divide and round half-up to 2 decimals. EUR to legacy: multiply and round half-up to the target exponent. Same currency: round the amount half-up to its exponent. Inverse rates are never used. Unknown codes return 'ERR:currency'.

Why this case matters

Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, frm, to):
    rates = {'DEM': '1.95583', 'FRF': '6.55957', 'ITL': '1936.27', 'ESP': '166.386', 'IEP': '0.787564', 'NLG': '2.20371', 'BEF': '40.3399', 'PTE': '200.482', 'ATS': '13.7603', 'FIM': '5.94573', 'EUR': '1'}
    zero = ('ITL', 'ESP', 'BEF', 'PTE')
    if frm not in rates or to not in rates: return 'ERR:currency'
    def q(v, c):
        return v.quantize(Decimal(1) if c in zero else Decimal('0.01'), rounding=ROUND_HALF_UP)
    x = Decimal(amount)
    if frm == to: return format(q(x, to), 'f')
    if frm == 'EUR':
        eur = x
    elif to == 'EUR':
        return format(q(x / Decimal(rates[frm]), 'EUR'), 'f')
    else:
        return format(q(x * (Decimal(rates[to]) / Decimal(rates[frm])).quantize(Decimal('1e-6')), to), 'f')
    return format(q(eur * Decimal(rates[to]), to), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression direct-cross-rate 1', ('100', 'DEM', 'FRF'), '335.38'),
  ('regression direct-cross-rate 2', ('123456', 'ESP', 'IEP'), '584.36'),
  ('partial repair guard 2', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency')],
 [('regression direct-cross-rate 1', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('regression direct-cross-rate 2', ('2542824', 'FRF', 'ESP'), '64499703'),
  ('partial repair guard 1', ('874590.00', 'DEM', 'ITL'), '865843339'),
  ('partial repair guard 2', ('2943493', 'NLG', 'ESP'), '222241596'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')],
 [('regression direct-cross-rate 1', ('2732281.35', 'DEM', 'FRF'), '9163675.15'),
  ('regression direct-cross-rate 2', ('1991579.94', 'NLG', 'DEM'), '1767560.97'),
  ('partial repair guard 1', ('3066738', 'BEF', 'ITL'), '147199987'),
  ('partial repair guard 2', ('404894', 'FIM', 'ITL'), '131856660'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1'),
  ('control: schilling to markka', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: franc to franc', ('12.345', 'BEF', 'FRF'), '2.01'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38')],
 [('regression direct-cross-rate 1', ('4401171', 'FIM', 'DEM'), '1447751.96'),
  ('regression direct-cross-rate 2', ('4407915', 'NLG', 'FRF'), '13120613.42'),
  ('partial repair guard 1', ('1491996', 'DEM', 'ATS'), '10496982.14'),
  ('partial repair guard 2', ('2701255', 'ESP', 'DEM'), '31752.65'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101')],
 [('regression direct-cross-rate 1', ('321003', 'BEF', 'DEM'), '15563.43'),
  ('regression direct-cross-rate 2', ('1369593', 'ATS', 'NLG'), '219340.12'),
  ('partial repair guard 1', ('2258512', 'PTE', 'ATS'), '155015.42'),
  ('partial repair guard 2', ('4761183', 'FRF', 'FIM'), '4315634.80'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')]]
for label, args, expected in cases[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 direct-cross-rate 1335.39335.38Failed
regression direct-cross-rate 2584.32584.36Failed
partial repair guard 2426.76426.75Failed
control: lira to euro516.46516.46Passed
control: euro to lira1936319363Passed
control: same currency rounding101101Passed
control: unknownERR:currencyERR:currencyPassed

SHA-256 / af501db333425843abeab02a174612ebd166859117b593d4762da65077e23dde

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, frm, to):
    rates = {'DEM': '1.95583', 'FRF': '6.55957', 'ITL': '1936.27', 'ESP': '166.386', 'IEP': '0.787564', 'NLG': '2.20371', 'BEF': '40.3399', 'PTE': '200.482', 'ATS': '13.7603', 'FIM': '5.94573', 'EUR': '1'}
    zero = ('ITL', 'ESP', 'BEF', 'PTE')
    if frm not in rates or to not in rates: return 'ERR:currency'
    def q(v, c):
        return v.quantize(Decimal(1) if c in zero else Decimal('0.01'), rounding=ROUND_HALF_UP)
    x = Decimal(amount)
    if frm == to: return format(q(x, to), 'f')
    if frm == 'EUR':
        eur = x
    elif to == 'EUR':
        return format(q(x / Decimal(rates[frm]), 'EUR'), 'f')
    else:
        return format(q(x * Decimal(rates[to]) / Decimal(rates[frm]), to), 'f')
    return format(q(eur * Decimal(rates[to]), to), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression direct-cross-rate 1', ('100', 'DEM', 'FRF'), '335.38'),
  ('regression direct-cross-rate 2', ('123456', 'ESP', 'IEP'), '584.36'),
  ('partial repair guard 2', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency')],
 [('regression direct-cross-rate 1', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('regression direct-cross-rate 2', ('2542824', 'FRF', 'ESP'), '64499703'),
  ('partial repair guard 1', ('874590.00', 'DEM', 'ITL'), '865843339'),
  ('partial repair guard 2', ('2943493', 'NLG', 'ESP'), '222241596'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')],
 [('regression direct-cross-rate 1', ('2732281.35', 'DEM', 'FRF'), '9163675.15'),
  ('regression direct-cross-rate 2', ('1991579.94', 'NLG', 'DEM'), '1767560.97'),
  ('partial repair guard 1', ('3066738', 'BEF', 'ITL'), '147199987'),
  ('partial repair guard 2', ('404894', 'FIM', 'ITL'), '131856660'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1'),
  ('control: schilling to markka', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: franc to franc', ('12.345', 'BEF', 'FRF'), '2.01'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38')],
 [('regression direct-cross-rate 1', ('4401171', 'FIM', 'DEM'), '1447751.96'),
  ('regression direct-cross-rate 2', ('4407915', 'NLG', 'FRF'), '13120613.42'),
  ('partial repair guard 1', ('1491996', 'DEM', 'ATS'), '10496982.14'),
  ('partial repair guard 2', ('2701255', 'ESP', 'DEM'), '31752.65'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101')],
 [('regression direct-cross-rate 1', ('321003', 'BEF', 'DEM'), '15563.43'),
  ('regression direct-cross-rate 2', ('1369593', 'ATS', 'NLG'), '219340.12'),
  ('partial repair guard 1', ('2258512', 'PTE', 'ATS'), '155015.42'),
  ('partial repair guard 2', ('4761183', 'FRF', 'FIM'), '4315634.80'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')]]
for label, args, expected in cases[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 direct-cross-rate 1335.39335.38Failed
regression direct-cross-rate 2584.36584.36Passed
partial repair guard 2426.76426.75Failed
control: lira to euro516.46516.46Passed
control: euro to lira1936319363Passed
control: same currency rounding101101Passed
control: unknownERR:currencyERR:currencyPassed

SHA-256 / 6480f22540bbb088f069ffddf306c78dd22b0687d5db7db4e48b3dd76d31f0f7

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, frm, to):
    rates = {'DEM': '1.95583', 'FRF': '6.55957', 'ITL': '1936.27', 'ESP': '166.386', 'IEP': '0.787564', 'NLG': '2.20371', 'BEF': '40.3399', 'PTE': '200.482', 'ATS': '13.7603', 'FIM': '5.94573', 'EUR': '1'}
    zero = ('ITL', 'ESP', 'BEF', 'PTE')
    if frm not in rates or to not in rates: return 'ERR:currency'
    def q(v, c):
        return v.quantize(Decimal(1) if c in zero else Decimal('0.01'), rounding=ROUND_HALF_UP)
    x = Decimal(amount)
    if frm == to: return format(q(x, to), 'f')
    if frm == 'EUR':
        eur = x
    elif to == 'EUR':
        return format(q(x / Decimal(rates[frm]), 'EUR'), 'f')
    else:
        eur = (x / Decimal(rates[frm])).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP)
    return format(q(eur * Decimal(rates[to]), to), 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression direct-cross-rate 1', ('100', 'DEM', 'FRF'), '335.38'),
  ('regression direct-cross-rate 2', ('123456', 'ESP', 'IEP'), '584.36'),
  ('partial repair guard 2', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency')],
 [('regression direct-cross-rate 1', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('regression direct-cross-rate 2', ('2542824', 'FRF', 'ESP'), '64499703'),
  ('partial repair guard 1', ('874590.00', 'DEM', 'ITL'), '865843339'),
  ('partial repair guard 2', ('2943493', 'NLG', 'ESP'), '222241596'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')],
 [('regression direct-cross-rate 1', ('2732281.35', 'DEM', 'FRF'), '9163675.15'),
  ('regression direct-cross-rate 2', ('1991579.94', 'NLG', 'DEM'), '1767560.97'),
  ('partial repair guard 1', ('3066738', 'BEF', 'ITL'), '147199987'),
  ('partial repair guard 2', ('404894', 'FIM', 'ITL'), '131856660'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1'),
  ('control: schilling to markka', ('987.65', 'ATS', 'FIM'), '426.75'),
  ('control: franc to franc', ('12.345', 'BEF', 'FRF'), '2.01'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38')],
 [('regression direct-cross-rate 1', ('4401171', 'FIM', 'DEM'), '1447751.96'),
  ('regression direct-cross-rate 2', ('4407915', 'NLG', 'FRF'), '13120613.42'),
  ('partial repair guard 1', ('1491996', 'DEM', 'ATS'), '10496982.14'),
  ('partial repair guard 2', ('2701255', 'ESP', 'DEM'), '31752.65'),
  ('control: mark to franc', ('100', 'DEM', 'FRF'), '335.38'),
  ('control: lira to euro', ('1000000', 'ITL', 'EUR'), '516.46'),
  ('control: euro to lira', ('10', 'EUR', 'ITL'), '19363'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101')],
 [('regression direct-cross-rate 1', ('321003', 'BEF', 'DEM'), '15563.43'),
  ('regression direct-cross-rate 2', ('1369593', 'ATS', 'NLG'), '219340.12'),
  ('partial repair guard 1', ('2258512', 'PTE', 'ATS'), '155015.42'),
  ('partial repair guard 2', ('4761183', 'FRF', 'FIM'), '4315634.80'),
  ('control: same currency rounding', ('100.5', 'ITL', 'ITL'), '101'),
  ('control: unknown', ('5', 'XEU', 'DEM'), 'ERR:currency'),
  ('control: peseta to punt', ('123456', 'ESP', 'IEP'), '584.36'),
  ('control: guilder to escudo', ('0.01', 'NLG', 'PTE'), '1')]]
for label, args, expected in cases[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 direct-cross-rate 1335.38335.38Passed
regression direct-cross-rate 2584.36584.36Passed
partial repair guard 2426.75426.75Passed
control: lira to euro516.46516.46Passed
control: euro to lira1936319363Passed
control: same currency rounding101101Passed
control: unknownERR:currencyERR:currencyPassed

SHA-256 / 36b42772385c0ca91279fdc96c05fdfbe5ede26b8c2611730f8d13faa8265b35

Verification & scope

A deterministic, bounded teaching model with a stipulated toy contract; it makes no claim of conformance to any real regulation, standard, or institution's rules. 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:46:59.856795+00:00.

Case digest / 7f94c6dee3e8766bffc57bd8182eb6831995076d025eb00d4f92a9711068d604