FAILURE MAP
← Case archive

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

The converted price is rounded to cents before charm pricing · case 01

A converted value of 11.994 is listed at 11.99, below the converted amount.

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

ROOT CAUSE

raw is quantized half-even to two decimals before the charm search.

VERIFIED REPAIR

Search charm prices against the exact converted value.

Unsuccessful approach: Pre-rounding to four decimals still hides sub-basis-point excess over a charm price.

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)).quantize(Decimal('0.01'), rounding=ROUND_HALF_EVEN)
    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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('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'),
  ('control: yen round up', ('1234.5', '1', 'JPY'), '1238')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('control: converted euro', ('10.00', '0.92', 'EUR'), '9.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')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 fixtureActualExpectedOutcome
regression pre-rounded-raw 111.9912.99Failed
regression pre-rounded-raw 211.9912.99Failed
control: whole number12.9912.99Passed
control: already charm11.9911.99Passed
control: above charm13.9913.99Passed
control: yen round up12381238Passed

SHA-256 / d6dcb665128ec7a1a66c6f9417d0cc39199a8ca116b2b5117fa33a997078adf3

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)).quantize(Decimal('0.0001'), rounding=ROUND_HALF_EVEN)
    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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('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'),
  ('control: yen round up', ('1234.5', '1', 'JPY'), '1238')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('control: converted euro', ('10.00', '0.92', 'EUR'), '9.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')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 fixtureActualExpectedOutcome
regression pre-rounded-raw 112.9912.99Passed
regression pre-rounded-raw 211.9912.99Failed
control: whole number12.9912.99Passed
control: already charm11.9911.99Passed
control: above charm13.9913.99Passed
control: yen round up12381238Passed

SHA-256 / 4f63509f4702a79d065a48202075f63039babc46095dcfa91cb6d51dffd49312

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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('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'),
  ('control: yen round up', ('1234.5', '1', 'JPY'), '1238')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.99'),
  ('control: converted euro', ('10.00', '0.92', 'EUR'), '9.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')],
 [('regression pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 pre-rounded-raw 1', ('11.994', '1', 'USD'), '12.99'),
  ('regression pre-rounded-raw 2', ('11.99004', '1', 'GBP'), '12.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 fixtureActualExpectedOutcome
regression pre-rounded-raw 112.9912.99Passed
regression pre-rounded-raw 212.9912.99Passed
control: whole number12.9912.99Passed
control: already charm11.9911.99Passed
control: above charm13.9913.99Passed
control: yen round up12381238Passed

SHA-256 / 85c1277ebb63e8aa05d8f74951cfb9bc22a2865e706ffa82b4bda54a184e5a7b

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

Case digest / 075de1fabb03a54d968df2973aa328612018824e238f3b6d6cc5145669150489