FAILURE MAP
← Case archive

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

A short fraction is read as minor units without right-padding · case 01

'12.5' dollars parses as 1205 cents.

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

ROOT CAUSE

The fraction digits are converted directly to an integer without padding to the exponent.

VERIFIED REPAIR

Right-pad the fraction with zeros to exactly exp digits.

Unsuccessful approach: Padding to a fixed two digits breaks three-decimal currencies.

Case contract

solve(text, locale, exp): parse a localized amount into integer minor units at exponent exp. Group/decimal separators: en ',' '.', de '.' ',', ch "'" '.', fr ' ' or U+202F and ','. An optional leading '-' marks a negative amount (including -0.xx). If grouping is used, the first group has 1-3 digits and every later group exactly 3. A decimal separator must be followed by digits. Fraction digits beyond exp are allowed only if they are zeros, otherwise 'ERR:precision'. Malformed text returns 'ERR:format'; an unknown locale 'ERR:locale'.

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

N = 1
observations = []
def solve(text, locale, exp):
    seps = {'en': (',', '.'), 'de': ('.', ','), 'ch': ("'", '.'), 'fr': (' \u202f', ',')}
    if locale not in seps: return 'ERR:locale'
    groups, dec = seps[locale]
    dig = lambda t: t != '' and all(c in '0123456789' for c in t)
    s = text.strip()
    neg = s.startswith('-')
    if neg: s = s[1:]
    whole, _, frac = s.partition(dec)
    for g in groups[1:]: whole = whole.replace(g, groups[0])
    parts = whole.split(groups[0])
    if not all(dig(p) for p in parts) or (dec in s and not dig(frac)): return 'ERR:format'
    if len(parts) > 1 and (len(parts[0]) > 3 or any(len(p) != 3 for p in parts[1:])): return 'ERR:format'
    if frac[exp:].strip('0'): return 'ERR:precision'
    frac = frac[:exp]
    v = int(''.join(parts)) * 10 ** exp + (int(frac) if frac else 0)
    return -v if neg else v
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-padding 1', ('12.5', 'en', 3), 12500),
  ('regression fraction-padding 2', ('1.234,5', 'de', 2), 123450),
  ('partial repair guard 2', ('12.05', 'ch', 3), 12050), ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision')],
 [('regression fraction-padding 1', ('12 345,6', 'fr', 2), 1234560),
  ('regression fraction-padding 2', ('12.05', 'ch', 3), 12050), ('partial repair guard 1', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 2', ('-999,50', 'fr', 3), -999500),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision'),
  ('control: bad grouping', ('1,23,4.00', 'en', 2), 'ERR:format'),
  ('control: dinar fraction', ('12.5', 'en', 3), 12500)],
 [('regression fraction-padding 1', ('999,1', 'fr', 2), 99910),
  ('regression fraction-padding 2', ('12,5', 'fr', 2), 1250), ('partial repair guard 1', ('-0.1', 'ch', 3), -100),
  ('partial repair guard 2', ('12345,5', 'de', 3), 12345500), ('control: dinar fraction', ('12.5', 'en', 3), 12500),
  ('control: swiss integer', ("1'000", 'ch', 0), 1000), ('control: french plain space', ('12 345,6', 'fr', 2), 1234560),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format')],
 [('regression fraction-padding 1', ("12'345.5", 'ch', 2), 1234550),
  ('regression fraction-padding 2', ('12,1', 'de', 2), 1210),
  ('partial repair guard 1', ('100000,5', 'de', 3), 100000500),
  ('partial repair guard 2', ('-999,1', 'de', 3), -999100),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
  ('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
  ('control: oversized first group', ('1234,567.00', 'en', 2), 'ERR:format'),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456)],
 [('regression fraction-padding 1', ('-12.345,1', 'de', 2), -1234510),
  ('regression fraction-padding 2', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 1', ('-1000,50', 'de', 3), -1000500),
  ('partial repair guard 2', ('12.345,50', 'de', 3), 12345500),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: german short fraction', ('1.234,5', 'de', 2), 123450),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450)]]
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 fraction-padding 11200512500Failed
regression fraction-padding 2123405123450Failed
partial repair guard 21200512050Failed
control: english grouping123456123456Passed
control: negative below one-50-50Passed
control: narrow space with trailing zero123450123450Passed
control: excess precisionERR:precisionERR:precisionPassed

SHA-256 / fb6f2f1dd712dffa35f2d0c5edc28b957f933baace8371d9426e74bc55fcb0f6

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(text, locale, exp):
    seps = {'en': (',', '.'), 'de': ('.', ','), 'ch': ("'", '.'), 'fr': (' \u202f', ',')}
    if locale not in seps: return 'ERR:locale'
    groups, dec = seps[locale]
    dig = lambda t: t != '' and all(c in '0123456789' for c in t)
    s = text.strip()
    neg = s.startswith('-')
    if neg: s = s[1:]
    whole, _, frac = s.partition(dec)
    for g in groups[1:]: whole = whole.replace(g, groups[0])
    parts = whole.split(groups[0])
    if not all(dig(p) for p in parts) or (dec in s and not dig(frac)): return 'ERR:format'
    if len(parts) > 1 and (len(parts[0]) > 3 or any(len(p) != 3 for p in parts[1:])): return 'ERR:format'
    if frac[exp:].strip('0'): return 'ERR:precision'
    frac = frac[:exp].ljust(2, '0')
    v = int(''.join(parts)) * 10 ** exp + (int(frac) if frac else 0)
    return -v if neg else v
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-padding 1', ('12.5', 'en', 3), 12500),
  ('regression fraction-padding 2', ('1.234,5', 'de', 2), 123450),
  ('partial repair guard 2', ('12.05', 'ch', 3), 12050), ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision')],
 [('regression fraction-padding 1', ('12 345,6', 'fr', 2), 1234560),
  ('regression fraction-padding 2', ('12.05', 'ch', 3), 12050), ('partial repair guard 1', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 2', ('-999,50', 'fr', 3), -999500),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision'),
  ('control: bad grouping', ('1,23,4.00', 'en', 2), 'ERR:format'),
  ('control: dinar fraction', ('12.5', 'en', 3), 12500)],
 [('regression fraction-padding 1', ('999,1', 'fr', 2), 99910),
  ('regression fraction-padding 2', ('12,5', 'fr', 2), 1250), ('partial repair guard 1', ('-0.1', 'ch', 3), -100),
  ('partial repair guard 2', ('12345,5', 'de', 3), 12345500), ('control: dinar fraction', ('12.5', 'en', 3), 12500),
  ('control: swiss integer', ("1'000", 'ch', 0), 1000), ('control: french plain space', ('12 345,6', 'fr', 2), 1234560),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format')],
 [('regression fraction-padding 1', ("12'345.5", 'ch', 2), 1234550),
  ('regression fraction-padding 2', ('12,1', 'de', 2), 1210),
  ('partial repair guard 1', ('100000,5', 'de', 3), 100000500),
  ('partial repair guard 2', ('-999,1', 'de', 3), -999100),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
  ('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
  ('control: oversized first group', ('1234,567.00', 'en', 2), 'ERR:format'),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456)],
 [('regression fraction-padding 1', ('-12.345,1', 'de', 2), -1234510),
  ('regression fraction-padding 2', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 1', ('-1000,50', 'de', 3), -1000500),
  ('partial repair guard 2', ('12.345,50', 'de', 3), 12345500),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: german short fraction', ('1.234,5', 'de', 2), 123450),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450)]]
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 fraction-padding 11205012500Failed
regression fraction-padding 2123450123450Passed
partial repair guard 21200512050Failed
control: english grouping123456123456Passed
control: negative below one-50-50Passed
control: narrow space with trailing zero123450123450Passed
control: excess precisionERR:precisionERR:precisionPassed

SHA-256 / a53a169fd6c68a76b2e50d3351be496304cfa2a98e4717e50f4b47b66b84ddd9

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(text, locale, exp):
    seps = {'en': (',', '.'), 'de': ('.', ','), 'ch': ("'", '.'), 'fr': (' \u202f', ',')}
    if locale not in seps: return 'ERR:locale'
    groups, dec = seps[locale]
    dig = lambda t: t != '' and all(c in '0123456789' for c in t)
    s = text.strip()
    neg = s.startswith('-')
    if neg: s = s[1:]
    whole, _, frac = s.partition(dec)
    for g in groups[1:]: whole = whole.replace(g, groups[0])
    parts = whole.split(groups[0])
    if not all(dig(p) for p in parts) or (dec in s and not dig(frac)): return 'ERR:format'
    if len(parts) > 1 and (len(parts[0]) > 3 or any(len(p) != 3 for p in parts[1:])): return 'ERR:format'
    if frac[exp:].strip('0'): return 'ERR:precision'
    frac = frac[:exp].ljust(exp, '0')
    v = int(''.join(parts)) * 10 ** exp + (int(frac) if frac else 0)
    return -v if neg else v
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-padding 1', ('12.5', 'en', 3), 12500),
  ('regression fraction-padding 2', ('1.234,5', 'de', 2), 123450),
  ('partial repair guard 2', ('12.05', 'ch', 3), 12050), ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision')],
 [('regression fraction-padding 1', ('12 345,6', 'fr', 2), 1234560),
  ('regression fraction-padding 2', ('12.05', 'ch', 3), 12050), ('partial repair guard 1', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 2', ('-999,50', 'fr', 3), -999500),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450),
  ('control: excess precision', ('12.345', 'en', 2), 'ERR:precision'),
  ('control: bad grouping', ('1,23,4.00', 'en', 2), 'ERR:format'),
  ('control: dinar fraction', ('12.5', 'en', 3), 12500)],
 [('regression fraction-padding 1', ('999,1', 'fr', 2), 99910),
  ('regression fraction-padding 2', ('12,5', 'fr', 2), 1250), ('partial repair guard 1', ('-0.1', 'ch', 3), -100),
  ('partial repair guard 2', ('12345,5', 'de', 3), 12345500), ('control: dinar fraction', ('12.5', 'en', 3), 12500),
  ('control: swiss integer', ("1'000", 'ch', 0), 1000), ('control: french plain space', ('12 345,6', 'fr', 2), 1234560),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format')],
 [('regression fraction-padding 1', ("12'345.5", 'ch', 2), 1234550),
  ('regression fraction-padding 2', ('12,1', 'de', 2), 1210),
  ('partial repair guard 1', ('100000,5', 'de', 3), 100000500),
  ('partial repair guard 2', ('-999,1', 'de', 3), -999100),
  ('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
  ('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
  ('control: oversized first group', ('1234,567.00', 'en', 2), 'ERR:format'),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456)],
 [('regression fraction-padding 1', ('-12.345,1', 'de', 2), -1234510),
  ('regression fraction-padding 2', ('999.50', 'ch', 3), 999500),
  ('partial repair guard 1', ('-1000,50', 'de', 3), -1000500),
  ('partial repair guard 2', ('12.345,50', 'de', 3), 12345500),
  ('control: english grouping', ('1,234.56', 'en', 2), 123456),
  ('control: german short fraction', ('1.234,5', 'de', 2), 123450),
  ('control: negative below one', ('-0,50', 'de', 2), -50),
  ('control: narrow space with trailing zero', ('1\u202f234,500', 'fr', 2), 123450)]]
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 fraction-padding 11250012500Passed
regression fraction-padding 2123450123450Passed
partial repair guard 21205012050Passed
control: english grouping123456123456Passed
control: negative below one-50-50Passed
control: narrow space with trailing zero123450123450Passed
control: excess precisionERR:precisionERR:precisionPassed

SHA-256 / 8f0dbdb41542cd89fb4815e995a97d3956de7e716ce89e70bd6bfd3fd8bcacc6

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

Case digest / ab611472cb9d884047a0a595de7ebe881551f253c6a8c7d5d6c31b36ea9926d9