FA-62156 / Currency rounding and FX conversion / Open access
The minor-unit fraction is not zero-padded on the left · case 01
105 cents renders as '$1.5'.
ROOT CAUSE
str(frac) is appended without left zero padding.
VERIFIED REPAIR
Left-pad the fraction with zeros to the exponent width.
Unsuccessful approach: Right-padding turns 1.05 into '1.50'.
Case contract
solve(minor, ccy): format integer minor units. Styles: USD '$' prefix, ',' groups, '.' decimal, 2 digits; EUR ' €' suffix, '.' groups, ',' decimal, 2; JPY '¥' prefix, ',' groups, 0 digits (no decimal separator); CHF 'CHF ' prefix, "'" groups, '.', 2; KWD 'KD ' prefix, ',', '.', 3. Group the whole part in threes from the right; the fraction is zero-padded to the exponent. A negative amount places '-' before everything. 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
N = 1
observations = []
def solve(minor, ccy):
spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
if ccy not in spec: return 'ERR:currency'
pre, suf, grp, dec, e = spec[ccy]
neg = minor < 0
major, frac = divmod(abs(minor), 10 ** e)
digits = str(major)
groups = []
while len(digits) > 3:
groups.insert(0, digits[-3:])
digits = digits[:-3]
groups.insert(0, digits)
body = grp.join(groups)
if e: body += dec + str(frac)
return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-zero-fill 1', (105, 'USD'), '$1.05'),
('regression fraction-zero-fill 2', (1005, 'KWD'), 'KD 1.005'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
('control: yen', (1234567, 'JPY'), '¥1,234,567')],
[('regression fraction-zero-fill 1', (100000000, 'EUR'), '1.000.000,00 €'),
('regression fraction-zero-fill 2', (-1000000, 'EUR'), '-10.000,00 €'),
('partial repair guard 1', (-50, 'KWD'), '-KD 0.050'), ('partial repair guard 2', (5, 'CHF'), 'CHF 0.05'),
('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"),
('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],
[('regression fraction-zero-fill 1', (0, 'CHF'), 'CHF 0.00'),
('regression fraction-zero-fill 2', (-100000, 'USD'), '-$1,000.00'),
('partial repair guard 1', (105, 'EUR'), '1,05 €'), ('partial repair guard 2', (5, 'EUR'), '0,05 €'),
('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
[('regression fraction-zero-fill 1', (-50, 'KWD'), '-KD 0.050'),
('regression fraction-zero-fill 2', (5, 'CHF'), 'CHF 0.05'), ('partial repair guard 1', (-105, 'EUR'), '-1,05 €'),
('partial repair guard 2', (-5, 'CHF'), '-CHF 0.05'), ('control: small dollars', (105, 'USD'), '$1.05'),
('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50')],
[('regression fraction-zero-fill 1', (1000, 'USD'), '$10.00'),
('regression fraction-zero-fill 2', (105, 'EUR'), '1,05 €'), ('partial repair guard 1', (-5, 'USD'), '-$0.05'),
('partial repair guard 2', (50, 'KWD'), 'KD 0.050'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),
('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
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 fraction-zero-fill 1 | $1.5 | $1.05 | Failed |
| regression fraction-zero-fill 2 | KD 1.5 | KD 1.005 | Failed |
| control: dollars | $1,234.50 | $1,234.50 | Passed |
| control: negative dollars | -$1.50 | -$1.50 | Passed |
| control: negative euro cents | -0,50 € | -0,50 € | Passed |
| control: yen | ¥1,234,567 | ¥1,234,567 | Passed |
SHA-256 / dc646f39c02f6f1348942d153ae45b5307d36875dce6125ba42c289f3555ea2e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(minor, ccy):
spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
if ccy not in spec: return 'ERR:currency'
pre, suf, grp, dec, e = spec[ccy]
neg = minor < 0
major, frac = divmod(abs(minor), 10 ** e)
digits = str(major)
groups = []
while len(digits) > 3:
groups.insert(0, digits[-3:])
digits = digits[:-3]
groups.insert(0, digits)
body = grp.join(groups)
if e: body += dec + str(frac).ljust(e, '0')
return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-zero-fill 1', (105, 'USD'), '$1.05'),
('regression fraction-zero-fill 2', (1005, 'KWD'), 'KD 1.005'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
('control: yen', (1234567, 'JPY'), '¥1,234,567')],
[('regression fraction-zero-fill 1', (100000000, 'EUR'), '1.000.000,00 €'),
('regression fraction-zero-fill 2', (-1000000, 'EUR'), '-10.000,00 €'),
('partial repair guard 1', (-50, 'KWD'), '-KD 0.050'), ('partial repair guard 2', (5, 'CHF'), 'CHF 0.05'),
('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"),
('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],
[('regression fraction-zero-fill 1', (0, 'CHF'), 'CHF 0.00'),
('regression fraction-zero-fill 2', (-100000, 'USD'), '-$1,000.00'),
('partial repair guard 1', (105, 'EUR'), '1,05 €'), ('partial repair guard 2', (5, 'EUR'), '0,05 €'),
('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
[('regression fraction-zero-fill 1', (-50, 'KWD'), '-KD 0.050'),
('regression fraction-zero-fill 2', (5, 'CHF'), 'CHF 0.05'), ('partial repair guard 1', (-105, 'EUR'), '-1,05 €'),
('partial repair guard 2', (-5, 'CHF'), '-CHF 0.05'), ('control: small dollars', (105, 'USD'), '$1.05'),
('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50')],
[('regression fraction-zero-fill 1', (1000, 'USD'), '$10.00'),
('regression fraction-zero-fill 2', (105, 'EUR'), '1,05 €'), ('partial repair guard 1', (-5, 'USD'), '-$0.05'),
('partial repair guard 2', (50, 'KWD'), 'KD 0.050'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),
('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
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 fraction-zero-fill 1 | $1.50 | $1.05 | Failed |
| regression fraction-zero-fill 2 | KD 1.500 | KD 1.005 | Failed |
| control: dollars | $1,234.50 | $1,234.50 | Passed |
| control: negative dollars | -$1.50 | -$1.50 | Passed |
| control: negative euro cents | -0,50 € | -0,50 € | Passed |
| control: yen | ¥1,234,567 | ¥1,234,567 | Passed |
SHA-256 / 47070ba18ffa382955698d43f08e044a654f2169fbdab6b929182de91537d9a5
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(minor, ccy):
spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', "'", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}
if ccy not in spec: return 'ERR:currency'
pre, suf, grp, dec, e = spec[ccy]
neg = minor < 0
major, frac = divmod(abs(minor), 10 ** e)
digits = str(major)
groups = []
while len(digits) > 3:
groups.insert(0, digits[-3:])
digits = digits[:-3]
groups.insert(0, digits)
body = grp.join(groups)
if e: body += dec + str(frac).zfill(e)
return ('-' if neg else '') + pre + body + suf
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression fraction-zero-fill 1', (105, 'USD'), '$1.05'),
('regression fraction-zero-fill 2', (1005, 'KWD'), 'KD 1.005'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
('control: yen', (1234567, 'JPY'), '¥1,234,567')],
[('regression fraction-zero-fill 1', (100000000, 'EUR'), '1.000.000,00 €'),
('regression fraction-zero-fill 2', (-1000000, 'EUR'), '-10.000,00 €'),
('partial repair guard 1', (-50, 'KWD'), '-KD 0.050'), ('partial repair guard 2', (5, 'CHF'), 'CHF 0.05'),
('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), "CHF 123'456.78"),
('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],
[('regression fraction-zero-fill 1', (0, 'CHF'), 'CHF 0.00'),
('regression fraction-zero-fill 2', (-100000, 'USD'), '-$1,000.00'),
('partial repair guard 1', (105, 'EUR'), '1,05 €'), ('partial repair guard 2', (5, 'EUR'), '0,05 €'),
('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),
('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],
[('regression fraction-zero-fill 1', (-50, 'KWD'), '-KD 0.050'),
('regression fraction-zero-fill 2', (5, 'CHF'), 'CHF 0.05'), ('partial repair guard 1', (-105, 'EUR'), '-1,05 €'),
('partial repair guard 2', (-5, 'CHF'), '-CHF 0.05'), ('control: small dollars', (105, 'USD'), '$1.05'),
('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50')],
[('regression fraction-zero-fill 1', (1000, 'USD'), '$10.00'),
('regression fraction-zero-fill 2', (105, 'EUR'), '1,05 €'), ('partial repair guard 1', (-5, 'USD'), '-$0.05'),
('partial repair guard 2', (50, 'KWD'), 'KD 0.050'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),
('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),
('control: franc', (12345678, 'CHF'), "CHF 123'456.78")]]
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 fraction-zero-fill 1 | $1.05 | $1.05 | Passed |
| regression fraction-zero-fill 2 | KD 1.005 | KD 1.005 | Passed |
| control: dollars | $1,234.50 | $1,234.50 | Passed |
| control: negative dollars | -$1.50 | -$1.50 | Passed |
| control: negative euro cents | -0,50 € | -0,50 € | Passed |
| control: yen | ¥1,234,567 | ¥1,234,567 | Passed |
SHA-256 / 8021f0fb61c01f3410fb903919064c41aff3c62ffa95e9f2800d1ee460c53e41
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.020763+00:00.
Case digest / cdb53fdea9689b7151d5cd144146b35894de0d0e9cd04d76df16d8fcf8bc6c07