FA-62121 / Currency rounding and FX conversion / Open access
Digit groups of any width are accepted · case 01
'1,23,4.00' is accepted as 1234.00 although it is not a valid grouped amount.
ROOT CAUSE
Group separators are removed without validating group widths.
VERIFIED REPAIR
Require a 1-3 digit leading group and exactly 3 digits in every later group.
Unsuccessful approach: Checking only the trailing groups still accepts an oversized leading group such as '1234,567'.
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 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 group-shape 1', ('1,23,4.00', 'en', 2), 'ERR:format'),
('regression group-shape 2', ('1234,567.00', 'en', 2), 'ERR:format'),
('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)],
[('regression group-shape 1', ('-100 1000,1', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ("1'1000.50", 'ch', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('-1 1000,123', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ('12.1345,123', 'de', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('100,1000.1', 'en', 3), 'ERR:format'),
('regression group-shape 2', ('12,1345', 'en', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
('control: english grouping', ('1,234.56', 'en', 2), 123456),
('control: german short fraction', ('1.234,5', 'de', 2), 123450)],
[('regression group-shape 1', ('100,1000.50', 'en', 2), 'ERR:format'),
('regression group-shape 2', ("1'1234'567.05", 'ch', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression group-shape 1 | 123400 | ERR:format | Failed |
| regression group-shape 2 | 123456700 | ERR:format | Failed |
| control: english grouping | 123456 | 123456 | Passed |
| control: german short fraction | 123450 | 123450 | Passed |
| control: negative below one | -50 | -50 | Passed |
| control: narrow space with trailing zero | 123450 | 123450 | Passed |
SHA-256 / e992830d3516ff556add128678a7f7c28e627aa4a44f78a0028e3ad4c9f087e8
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 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 group-shape 1', ('1,23,4.00', 'en', 2), 'ERR:format'),
('regression group-shape 2', ('1234,567.00', 'en', 2), 'ERR:format'),
('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)],
[('regression group-shape 1', ('-100 1000,1', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ("1'1000.50", 'ch', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('-1 1000,123', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ('12.1345,123', 'de', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('100,1000.1', 'en', 3), 'ERR:format'),
('regression group-shape 2', ('12,1345', 'en', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
('control: english grouping', ('1,234.56', 'en', 2), 123456),
('control: german short fraction', ('1.234,5', 'de', 2), 123450)],
[('regression group-shape 1', ('100,1000.50', 'en', 2), 'ERR:format'),
('regression group-shape 2', ("1'1234'567.05", 'ch', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression group-shape 1 | ERR:format | ERR:format | Passed |
| regression group-shape 2 | 123456700 | ERR:format | Failed |
| control: english grouping | 123456 | 123456 | Passed |
| control: german short fraction | 123450 | 123450 | Passed |
| control: negative below one | -50 | -50 | Passed |
| control: narrow space with trailing zero | 123450 | 123450 | Passed |
SHA-256 / ef6bfab2e4c709a860ce3553b051257be32f9b0dfea4f4f2d8209541d6b886cd
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 group-shape 1', ('1,23,4.00', 'en', 2), 'ERR:format'),
('regression group-shape 2', ('1234,567.00', 'en', 2), 'ERR:format'),
('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)],
[('regression group-shape 1', ('-100 1000,1', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ("1'1000.50", 'ch', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('-1 1000,123', 'fr', 3), 'ERR:format'),
('regression group-shape 2', ('12.1345,123', 'de', 2), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 group-shape 1', ('100,1000.1', 'en', 3), 'ERR:format'),
('regression group-shape 2', ('12,1345', 'en', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('control: dangling separator', ('12.', 'en', 2), 'ERR:format'),
('control: unknown locale', ('12', 'it', 2), 'ERR:locale'),
('control: english grouping', ('1,234.56', 'en', 2), 123456),
('control: german short fraction', ('1.234,5', 'de', 2), 123450)],
[('regression group-shape 1', ('100,1000.50', 'en', 2), 'ERR:format'),
('regression group-shape 2', ("1'1234'567.05", 'ch', 3), 'ERR:format'),
('partial repair guard 1', ('1234,567.00', 'en', 2), 'ERR:format'),
('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression group-shape 1 | ERR:format | ERR:format | Passed |
| regression group-shape 2 | ERR:format | ERR:format | Passed |
| control: english grouping | 123456 | 123456 | Passed |
| control: german short fraction | 123450 | 123450 | Passed |
| control: negative below one | -50 | -50 | Passed |
| control: narrow space with trailing zero | 123450 | 123450 | Passed |
SHA-256 / f7a10b6ff9ffeb32b4f92505753e35ed665934ea71de271f7970c2c081aa9679
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.687736+00:00.
Case digest / 3d936d160337e1a0898822d66a484ab3b1082448563f419cbe5a90801715a099