FAILURE MAP
← Case archive

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

The card amount is computed from the unrounded offered rate · case 01

The receipt shows a rate that does not reproduce the charged card amount.

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

ROOT CAUSE

The card amount multiplies by the raw marked-up rate instead of the 6-decimal rate printed on the receipt.

VERIFIED REPAIR

Round the offered rate first and charge amount * rounded rate.

Unsuccessful approach: Printing and charging a 4-decimal rate is consistent but not the stipulated 6-decimal rate.

Case contract

solve(amount, ref_rate, markup_bps, card_exp): amount in merchant currency, ref_rate cardholder units per merchant unit, markup_bps an integer (negative for a promotional discount). The offered rate is ref*(1+bps/10000) rounded half-up to 6 decimals, and the card amount is amount*offered rounded half-up at card_exp. The disclosed markup percentage is (offered/ref - 1)*100 computed from the rounded offered rate and rounded toward positive infinity to 2 decimals so it never understates. Return [offered, card_amount, markup_pct] as strings.

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, ref_rate, markup_bps, card_exp):
    ref = Decimal(ref_rate)
    raw = ref * (1 + Decimal(markup_bps) / 10000)
    dcc = raw.quantize(Decimal('0.000001'), rounding=ROUND_HALF_UP)
    card = (Decimal(amount) * raw).quantize(Decimal(1).scaleb(-card_exp), rounding=ROUND_HALF_UP)
    pct = ((dcc / ref - 1) * 100).quantize(Decimal('0.01'), rounding=ROUND_CEILING)
    return [format(dcc, 'f'), format(card, 'f'), format(pct, 'f')]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression offered-rate-rounding-stage 1', ('3786.84', '0.8838869', 0, 3), ['0.883887', '3347.139', '0.01']),
  ('regression offered-rate-rounding-stage 2', ('4785.79', '0.3571554', 275, 3), ['0.366977', '1756.275', '2.75']),
  ('partial repair guard 1', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('partial repair guard 2', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00'])],
 [('regression offered-rate-rounding-stage 1', ('2828.89', '177.96716', 300, 2), ['183.306175', '518553.01', '3.01']),
  ('regression offered-rate-rounding-stage 2', ('2562.31', '84.27230', -50, 3), ['83.850939', '214852.100', '-0.49']),
  ('partial repair guard 1', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('partial repair guard 2', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51'])],
 [('regression offered-rate-rounding-stage 1', ('4714.25', '1.339649', 150, 3), ['1.359744', '6410.173', '1.51']),
  ('regression offered-rate-rounding-stage 2', ('4302.97', '76.37837', -75, 3), ['75.805532', '326188.930', '-0.75']),
  ('partial repair guard 1', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('partial repair guard 2', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])],
 [('regression offered-rate-rounding-stage 1', ('3179.28', '171.61510', 350, 3), ['177.621629', '564708.893', '3.51']),
  ('regression offered-rate-rounding-stage 2', ('1646.82', '0.4182731', 275, 3), ['0.429776', '707.764', '2.76']),
  ('partial repair guard 1', ('3353.43', '37.36650', 275, 0), ['38.394079', '128752', '2.76']),
  ('partial repair guard 2', ('1171.26', '0.4683115', -50, 3), ['0.465970', '545.772', '-0.49']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00'])],
 [('regression offered-rate-rounding-stage 1', ('3487.14', '1.2723004', 0, 3), ['1.272300', '4436.688', '-0.00']),
  ('regression offered-rate-rounding-stage 2', ('1594.17', '96.28226', 350, 3), ['99.652139', '158862.450', '3.50']),
  ('partial repair guard 1', ('3884.23', '183.00464', 350, 0), ['189.409802', '735711', '3.50']),
  ('partial repair guard 2', ('157.22', '31.44890', 150, 3), ['31.920634', '5018.562', '1.51']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])]]
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 offered-rate-rounding-stage 1['0.883887', '3347.138', '0.01']['0.883887', '3347.139', '0.01']Failed
regression offered-rate-rounding-stage 2['0.366977', '1756.276', '2.75']['0.366977', '1756.275', '2.75']Failed
partial repair guard 1['1.115975', '111.60', '3.00']['1.115975', '111.60', '3.00']Passed
partial repair guard 2['0.006852', '34.26', '3.51']['0.006852', '34.26', '3.51']Passed
control: to yen card['155.536991', '7775', '2.76']['155.536991', '7775', '2.76']Passed
control: dinar card['0.319418', '79.855', '4.00']['0.319418', '79.855', '4.00']Passed
control: promotional discount['0.908810', '72.70', '-0.50']['0.908810', '72.70', '-0.50']Passed
control: zero markup['1.200000', '14.81', '0.00']['1.200000', '14.81', '0.00']Passed

SHA-256 / b93c3343835f7eca3ba25ed5121019164873a5ad98ea96a3536e710d22ec295c

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, ref_rate, markup_bps, card_exp):
    ref = Decimal(ref_rate)
    raw = ref * (1 + Decimal(markup_bps) / 10000)
    dcc = raw.quantize(Decimal('0.0001'), rounding=ROUND_HALF_UP)
    card = (Decimal(amount) * dcc).quantize(Decimal(1).scaleb(-card_exp), rounding=ROUND_HALF_UP)
    pct = ((dcc / ref - 1) * 100).quantize(Decimal('0.01'), rounding=ROUND_CEILING)
    return [format(dcc, 'f'), format(card, 'f'), format(pct, 'f')]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression offered-rate-rounding-stage 1', ('3786.84', '0.8838869', 0, 3), ['0.883887', '3347.139', '0.01']),
  ('regression offered-rate-rounding-stage 2', ('4785.79', '0.3571554', 275, 3), ['0.366977', '1756.275', '2.75']),
  ('partial repair guard 1', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('partial repair guard 2', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00'])],
 [('regression offered-rate-rounding-stage 1', ('2828.89', '177.96716', 300, 2), ['183.306175', '518553.01', '3.01']),
  ('regression offered-rate-rounding-stage 2', ('2562.31', '84.27230', -50, 3), ['83.850939', '214852.100', '-0.49']),
  ('partial repair guard 1', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('partial repair guard 2', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51'])],
 [('regression offered-rate-rounding-stage 1', ('4714.25', '1.339649', 150, 3), ['1.359744', '6410.173', '1.51']),
  ('regression offered-rate-rounding-stage 2', ('4302.97', '76.37837', -75, 3), ['75.805532', '326188.930', '-0.75']),
  ('partial repair guard 1', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('partial repair guard 2', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])],
 [('regression offered-rate-rounding-stage 1', ('3179.28', '171.61510', 350, 3), ['177.621629', '564708.893', '3.51']),
  ('regression offered-rate-rounding-stage 2', ('1646.82', '0.4182731', 275, 3), ['0.429776', '707.764', '2.76']),
  ('partial repair guard 1', ('3353.43', '37.36650', 275, 0), ['38.394079', '128752', '2.76']),
  ('partial repair guard 2', ('1171.26', '0.4683115', -50, 3), ['0.465970', '545.772', '-0.49']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00'])],
 [('regression offered-rate-rounding-stage 1', ('3487.14', '1.2723004', 0, 3), ['1.272300', '4436.688', '-0.00']),
  ('regression offered-rate-rounding-stage 2', ('1594.17', '96.28226', 350, 3), ['99.652139', '158862.450', '3.50']),
  ('partial repair guard 1', ('3884.23', '183.00464', 350, 0), ['189.409802', '735711', '3.50']),
  ('partial repair guard 2', ('157.22', '31.44890', 150, 3), ['31.920634', '5018.562', '1.51']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])]]
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 offered-rate-rounding-stage 1['0.8839', '3347.188', '0.01']['0.883887', '3347.139', '0.01']Failed
regression offered-rate-rounding-stage 2['0.3670', '1756.385', '2.76']['0.366977', '1756.275', '2.75']Failed
partial repair guard 1['1.1160', '111.60', '3.01']['1.115975', '111.60', '3.00']Failed
partial repair guard 2['0.0069', '34.50', '4.23']['0.006852', '34.26', '3.51']Failed
control: to yen card['155.5370', '7775', '2.76']['155.536991', '7775', '2.76']Failed
control: dinar card['0.3194', '79.850', '4.00']['0.319418', '79.855', '4.00']Failed
control: promotional discount['0.9088', '72.70', '-0.50']['0.908810', '72.70', '-0.50']Failed
control: zero markup['1.2000', '14.81', '0.00']['1.200000', '14.81', '0.00']Failed

SHA-256 / 57844e0a28ff0841ba1ec81dab82a70545a562fc824a6e3be9f1ea952132f138

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, ref_rate, markup_bps, card_exp):
    ref = Decimal(ref_rate)
    raw = ref * (1 + Decimal(markup_bps) / 10000)
    dcc = raw.quantize(Decimal('0.000001'), rounding=ROUND_HALF_UP)
    card = (Decimal(amount) * dcc).quantize(Decimal(1).scaleb(-card_exp), rounding=ROUND_HALF_UP)
    pct = ((dcc / ref - 1) * 100).quantize(Decimal('0.01'), rounding=ROUND_CEILING)
    return [format(dcc, 'f'), format(card, 'f'), format(pct, 'f')]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression offered-rate-rounding-stage 1', ('3786.84', '0.8838869', 0, 3), ['0.883887', '3347.139', '0.01']),
  ('regression offered-rate-rounding-stage 2', ('4785.79', '0.3571554', 275, 3), ['0.366977', '1756.275', '2.75']),
  ('partial repair guard 1', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('partial repair guard 2', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00'])],
 [('regression offered-rate-rounding-stage 1', ('2828.89', '177.96716', 300, 2), ['183.306175', '518553.01', '3.01']),
  ('regression offered-rate-rounding-stage 2', ('2562.31', '84.27230', -50, 3), ['83.850939', '214852.100', '-0.49']),
  ('partial repair guard 1', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('partial repair guard 2', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51'])],
 [('regression offered-rate-rounding-stage 1', ('4714.25', '1.339649', 150, 3), ['1.359744', '6410.173', '1.51']),
  ('regression offered-rate-rounding-stage 2', ('4302.97', '76.37837', -75, 3), ['75.805532', '326188.930', '-0.75']),
  ('partial repair guard 1', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('partial repair guard 2', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])],
 [('regression offered-rate-rounding-stage 1', ('3179.28', '171.61510', 350, 3), ['177.621629', '564708.893', '3.51']),
  ('regression offered-rate-rounding-stage 2', ('1646.82', '0.4182731', 275, 3), ['0.429776', '707.764', '2.76']),
  ('partial repair guard 1', ('3353.43', '37.36650', 275, 0), ['38.394079', '128752', '2.76']),
  ('partial repair guard 2', ('1171.26', '0.4683115', -50, 3), ['0.465970', '545.772', '-0.49']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00']),
  ('control: promotional discount', ('80.00', '0.913377', -50, 2), ['0.908810', '72.70', '-0.50']),
  ('control: zero markup', ('12.34', '1.2', 0, 2), ['1.200000', '14.81', '0.00']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00'])],
 [('regression offered-rate-rounding-stage 1', ('3487.14', '1.2723004', 0, 3), ['1.272300', '4436.688', '-0.00']),
  ('regression offered-rate-rounding-stage 2', ('1594.17', '96.28226', 350, 3), ['99.652139', '158862.450', '3.50']),
  ('partial repair guard 1', ('3884.23', '183.00464', 350, 0), ['189.409802', '735711', '3.50']),
  ('partial repair guard 2', ('157.22', '31.44890', 150, 3), ['31.920634', '5018.562', '1.51']),
  ('control: euro to dollar', ('100.00', '1.083471', 300, 2), ['1.115975', '111.60', '3.00']),
  ('control: yen to dollar', ('5000', '0.00662', 350, 2), ['0.006852', '34.26', '3.51']),
  ('control: to yen card', ('49.99', '151.3742', 275, 0), ['155.536991', '7775', '2.76']),
  ('control: dinar card', ('250.00', '0.307133', 400, 3), ['0.319418', '79.855', '4.00'])]]
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 offered-rate-rounding-stage 1['0.883887', '3347.139', '0.01']['0.883887', '3347.139', '0.01']Passed
regression offered-rate-rounding-stage 2['0.366977', '1756.275', '2.75']['0.366977', '1756.275', '2.75']Passed
partial repair guard 1['1.115975', '111.60', '3.00']['1.115975', '111.60', '3.00']Passed
partial repair guard 2['0.006852', '34.26', '3.51']['0.006852', '34.26', '3.51']Passed
control: to yen card['155.536991', '7775', '2.76']['155.536991', '7775', '2.76']Passed
control: dinar card['0.319418', '79.855', '4.00']['0.319418', '79.855', '4.00']Passed
control: promotional discount['0.908810', '72.70', '-0.50']['0.908810', '72.70', '-0.50']Passed
control: zero markup['1.200000', '14.81', '0.00']['1.200000', '14.81', '0.00']Passed

SHA-256 / 11fb0c219266f32043f2ad31fd31e248c9e347431f57bd298e1c626324a14f32

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

Case digest / ede9987384b9a9a4836428b265e8698ac71fd8098c3cea67eb95fd8907b23780