FA-62301 / Currency rounding and FX conversion / Open access
Charm pricing subtracts a cent from the ceiling · case 01
A converted price of exactly 12.00 is listed at 11.99, below the converted value.
ROOT CAUSE
The charm price is computed as ceil(raw) - 0.01 without checking that it is not below raw.
VERIFIED REPAIR
Take floor(raw) + 0.99 and move up one unit if that is still below raw.
Unsuccessful approach: Bumping only when raw is a whole number still under-prices values between n.99 and n+1.
Case contract
solve(price, rate, ccy): a price list converted at rate is re-priced to the smallest charm price not below the exact converted value raw = price*rate. For JPY, charm prices end in 8 (…8 yen, i.e. 10k-2). For other currencies, charm prices end in .99. Return the charm price as a plain string.
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(price, rate, ccy):
raw = Decimal(price) * Decimal(rate)
if ccy == 'JPY':
c = (raw / 10).to_integral_value(rounding=ROUND_CEILING) * 10 - 2
if c < raw: c += 10
return format(c, 'f')
c = raw.to_integral_value(rounding=ROUND_CEILING) - Decimal('0.01')
return format(c, 'f')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression whole-unit-boundary 1', ('12.00', '1', 'EUR'), '12.99'),
('regression whole-unit-boundary 2', ('12.995', '1', 'EUR'), '13.99'),
('partial repair guard 2', ('11.994', '1', 'USD'), '12.99'),
('control: already charm', ('11.99', '1', 'EUR'), '11.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')],
[('regression whole-unit-boundary 1', ('11.994', '1', 'USD'), '12.99'),
('regression whole-unit-boundary 2', ('11.99004', '1', 'GBP'), '12.99'),
('partial repair guard 2', ('1671.9996', '1', 'USD'), '1672.99'),
('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99')],
[('regression whole-unit-boundary 1', ('1671.9996', '1', 'USD'), '1672.99'),
('regression whole-unit-boundary 2', ('2820.995', '1', 'USD'), '2821.99'),
('partial repair guard 2', ('2931.999', '1', 'EUR'), '2932.99'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99'),
('control: just above charm', ('11.994', '1', 'USD'), '12.99'),
('control: sub-cent above', ('11.99004', '1', 'GBP'), '12.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518')],
[('regression whole-unit-boundary 1', ('2931.999', '1', 'EUR'), '2932.99'),
('regression whole-unit-boundary 2', ('1682.999', '1', 'GBP'), '1683.99'),
('partial repair guard 2', ('2543.999', '1', 'USD'), '2544.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518'),
('control: whole number', ('12.00', '1', 'EUR'), '12.99'), ('control: already charm', ('11.99', '1', 'EUR'), '11.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99')],
[('regression whole-unit-boundary 1', ('2543.999', '1', 'USD'), '2544.99'),
('regression whole-unit-boundary 2', ('2655.9996', '1', 'GBP'), '2656.99'),
('partial repair guard 2', ('1127.995', '1', 'USD'), '1128.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')]]
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 whole-unit-boundary 1 | 11.99 | 12.99 | Failed |
| regression whole-unit-boundary 2 | 12.99 | 13.99 | Failed |
| partial repair guard 2 | 11.99 | 12.99 | Failed |
| control: already charm | 11.99 | 11.99 | Passed |
| control: yen round up | 1238 | 1238 | Passed |
| control: yen above ending | 1248 | 1248 | Passed |
| control: yen exact ending | 1238 | 1238 | Passed |
SHA-256 / 77e876cfe14af37ee60f48ba0a4bbcf8fc5917c3ad421dddddfce88c6b4e250c
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(price, rate, ccy):
raw = Decimal(price) * Decimal(rate)
if ccy == 'JPY':
c = (raw / 10).to_integral_value(rounding=ROUND_CEILING) * 10 - 2
if c < raw: c += 10
return format(c, 'f')
c = raw.to_integral_value(rounding=ROUND_CEILING) - Decimal('0.01')
if raw == raw.to_integral_value(): c += 1
return format(c, 'f')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression whole-unit-boundary 1', ('12.00', '1', 'EUR'), '12.99'),
('regression whole-unit-boundary 2', ('12.995', '1', 'EUR'), '13.99'),
('partial repair guard 2', ('11.994', '1', 'USD'), '12.99'),
('control: already charm', ('11.99', '1', 'EUR'), '11.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')],
[('regression whole-unit-boundary 1', ('11.994', '1', 'USD'), '12.99'),
('regression whole-unit-boundary 2', ('11.99004', '1', 'GBP'), '12.99'),
('partial repair guard 2', ('1671.9996', '1', 'USD'), '1672.99'),
('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99')],
[('regression whole-unit-boundary 1', ('1671.9996', '1', 'USD'), '1672.99'),
('regression whole-unit-boundary 2', ('2820.995', '1', 'USD'), '2821.99'),
('partial repair guard 2', ('2931.999', '1', 'EUR'), '2932.99'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99'),
('control: just above charm', ('11.994', '1', 'USD'), '12.99'),
('control: sub-cent above', ('11.99004', '1', 'GBP'), '12.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518')],
[('regression whole-unit-boundary 1', ('2931.999', '1', 'EUR'), '2932.99'),
('regression whole-unit-boundary 2', ('1682.999', '1', 'GBP'), '1683.99'),
('partial repair guard 2', ('2543.999', '1', 'USD'), '2544.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518'),
('control: whole number', ('12.00', '1', 'EUR'), '12.99'), ('control: already charm', ('11.99', '1', 'EUR'), '11.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99')],
[('regression whole-unit-boundary 1', ('2543.999', '1', 'USD'), '2544.99'),
('regression whole-unit-boundary 2', ('2655.9996', '1', 'GBP'), '2656.99'),
('partial repair guard 2', ('1127.995', '1', 'USD'), '1128.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')]]
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 whole-unit-boundary 1 | 12.99 | 12.99 | Passed |
| regression whole-unit-boundary 2 | 12.99 | 13.99 | Failed |
| partial repair guard 2 | 11.99 | 12.99 | Failed |
| control: already charm | 11.99 | 11.99 | Passed |
| control: yen round up | 1238 | 1238 | Passed |
| control: yen above ending | 1248 | 1248 | Passed |
| control: yen exact ending | 1238 | 1238 | Passed |
SHA-256 / b0821b57473928a09266907560baf60f650b9dbf52926d1e62b1d21730c7494a
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(price, rate, ccy):
raw = Decimal(price) * Decimal(rate)
if ccy == 'JPY':
c = (raw / 10).to_integral_value(rounding=ROUND_CEILING) * 10 - 2
if c < raw: c += 10
return format(c, 'f')
c = raw.to_integral_value(rounding=ROUND_FLOOR) + Decimal('0.99')
if c < raw: c += 1
return format(c, 'f')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression whole-unit-boundary 1', ('12.00', '1', 'EUR'), '12.99'),
('regression whole-unit-boundary 2', ('12.995', '1', 'EUR'), '13.99'),
('partial repair guard 2', ('11.994', '1', 'USD'), '12.99'),
('control: already charm', ('11.99', '1', 'EUR'), '11.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')],
[('regression whole-unit-boundary 1', ('11.994', '1', 'USD'), '12.99'),
('regression whole-unit-boundary 2', ('11.99004', '1', 'GBP'), '12.99'),
('partial repair guard 2', ('1671.9996', '1', 'USD'), '1672.99'),
('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99')],
[('regression whole-unit-boundary 1', ('1671.9996', '1', 'USD'), '1672.99'),
('regression whole-unit-boundary 2', ('2820.995', '1', 'USD'), '2821.99'),
('partial repair guard 2', ('2931.999', '1', 'EUR'), '2932.99'),
('control: converted euro', ('10.00', '0.92', 'EUR'), '9.99'),
('control: just above charm', ('11.994', '1', 'USD'), '12.99'),
('control: sub-cent above', ('11.99004', '1', 'GBP'), '12.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518')],
[('regression whole-unit-boundary 1', ('2931.999', '1', 'EUR'), '2932.99'),
('regression whole-unit-boundary 2', ('1682.999', '1', 'GBP'), '1683.99'),
('partial repair guard 2', ('2543.999', '1', 'USD'), '2544.99'),
('control: yen converted', ('9.99', '151.37', 'JPY'), '1518'),
('control: whole number', ('12.00', '1', 'EUR'), '12.99'), ('control: already charm', ('11.99', '1', 'EUR'), '11.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99')],
[('regression whole-unit-boundary 1', ('2543.999', '1', 'USD'), '2544.99'),
('regression whole-unit-boundary 2', ('2655.9996', '1', 'GBP'), '2656.99'),
('partial repair guard 2', ('1127.995', '1', 'USD'), '1128.99'),
('control: above charm', ('12.995', '1', 'EUR'), '13.99'), ('control: yen round up', ('1234.5', '1', 'JPY'), '1238'),
('control: yen above ending', ('1239', '1', 'JPY'), '1248'),
('control: yen exact ending', ('1238', '1', 'JPY'), '1238')]]
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 whole-unit-boundary 1 | 12.99 | 12.99 | Passed |
| regression whole-unit-boundary 2 | 13.99 | 13.99 | Passed |
| partial repair guard 2 | 12.99 | 12.99 | Passed |
| control: already charm | 11.99 | 11.99 | Passed |
| control: yen round up | 1238 | 1238 | Passed |
| control: yen above ending | 1248 | 1248 | Passed |
| control: yen exact ending | 1238 | 1238 | Passed |
SHA-256 / 22eccb17c9ea429188da5c4c24325ad2c20a2f0910c432794eb3b807ffb03cb6
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:03.364447+00:00.
Case digest / 5e62939ba6f40ac9162a36d0e284329261a9a84551601c635fa48d6509c97e57