FA-62151 / Currency rounding and FX conversion / Open access
A zero-decimal currency is printed with a decimal separator · case 01
Yen amounts render as '¥1,234,567.0'.
ROOT CAUSE
The fraction is appended unconditionally even when the exponent is zero.
THE FAILURE
The fraction is appended unconditionally even when the exponent is zero.
Unsuccessful approach: Dropping only the separator still appends the zero remainder as an extra digit.
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)
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 zero-exponent-separator 1', (1234567, 'JPY'), '¥1,234,567'),
('regression zero-exponent-separator 2', (0, 'JPY'), '¥0'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
('control: franc', (12345678, 'CHF'), "CHF 123'456.78")],
[('regression zero-exponent-separator 1', (-1000, 'JPY'), '-¥1,000'),
('regression zero-exponent-separator 2', (99999, 'JPY'), '¥99,999'), ('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 zero-exponent-separator 1', (5, 'JPY'), '¥5'),
('regression zero-exponent-separator 2', (100000, 'JPY'), '¥100,000'),
('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 zero-exponent-separator 1', (-999, 'JPY'), '-¥999'),
('regression zero-exponent-separator 2', (-105, 'JPY'), '-¥105'), ('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 zero-exponent-separator 1', (123456, 'JPY'), '¥123,456'),
('regression zero-exponent-separator 2', (987654321, 'JPY'), '¥987,654,321'),
('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 zero-exponent-separator 1 | ¥1,234,567.0 | ¥1,234,567 | Failed |
| regression zero-exponent-separator 2 | ¥0.0 | ¥0 | 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: franc | CHF 123'456.78 | CHF 123'456.78 | Passed |
SHA-256 / 123ada3e2951f3ec0233ef23bd75664b43183a4fb011181378b3e2f8064dee18
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)
body += (dec if e else '') + 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 zero-exponent-separator 1', (1234567, 'JPY'), '¥1,234,567'),
('regression zero-exponent-separator 2', (0, 'JPY'), '¥0'), ('control: dollars', (123450, 'USD'), '$1,234.50'),
('control: negative dollars', (-150, 'USD'), '-$1.50'), ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'),
('control: franc', (12345678, 'CHF'), "CHF 123'456.78")],
[('regression zero-exponent-separator 1', (-1000, 'JPY'), '-¥1,000'),
('regression zero-exponent-separator 2', (99999, 'JPY'), '¥99,999'), ('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 zero-exponent-separator 1', (5, 'JPY'), '¥5'),
('regression zero-exponent-separator 2', (100000, 'JPY'), '¥100,000'),
('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 zero-exponent-separator 1', (-999, 'JPY'), '-¥999'),
('regression zero-exponent-separator 2', (-105, 'JPY'), '-¥105'), ('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 zero-exponent-separator 1', (123456, 'JPY'), '¥123,456'),
('regression zero-exponent-separator 2', (987654321, 'JPY'), '¥987,654,321'),
('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 zero-exponent-separator 1 | ¥1,234,5670 | ¥1,234,567 | Failed |
| regression zero-exponent-separator 2 | ¥00 | ¥0 | 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: franc | CHF 123'456.78 | CHF 123'456.78 | Passed |
SHA-256 / a5a08fcd4d2e694183a74ecb167a001ad7d6f82a482fa860458e48b4da69bfae
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.001999+00:00.
Case digest / bbf0cdddea62c07528739869372a796d5d36afd75069a139c23d8bc1ef27b5f8