FAILURE MAP
← Case archive

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

A move exactly at the tolerance is computed in floating point · case 01

A 10% move against a 1000 bps band is rejected by a few ulps.

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

ROOT CAUSE

The deviation is computed with float division, so an exact boundary lands just above the limit.

VERIFIED REPAIR

Compute the deviation with exact decimals and compare inclusively.

Unsuccessful approach: Using float arithmetic with a strict comparison rejects every exact boundary.

Case contract

solve(new, ref, tol_bps, inverted): accept a newly published rate if |n - ref| / ref * 10000 <= tol_bps using exact decimals, where n = new, or 1/new when the new quote arrives inverted. A non-positive new or ref returns 'ERR:rate'. Return 'accept' or 'reject'.

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(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(float(n) - float(r)) / float(r)
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-boundary 1', ('1.1', '1.0', 1000, False), 'accept'),
  ('regression band-boundary 2', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('1.0835', '1.0835', 0, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('2.015556', '1.9956', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('partial repair guard 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('partial repair guard 2', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')],
 [('regression band-boundary 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('regression band-boundary 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('2.015556', '1.9956', 100, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression band-boundary 1', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('regression band-boundary 2', ('1.29844', '1.1804', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('1.886276', '1.8676', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.68751', '1.5341', 1000, False), 'accept'),
  ('partial repair guard 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('partial repair guard 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
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 band-boundary 1rejectacceptFailed
regression band-boundary 2rejectacceptFailed
partial repair guard 2acceptacceptPassed
control: lower boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: inverted exactacceptacceptPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 0e7d97ff480543a26194beac65aaaaf4d392f7d6f85d83cf3ae5a66f6583863d

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(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 < tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-boundary 1', ('1.1', '1.0', 1000, False), 'accept'),
  ('regression band-boundary 2', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('1.0835', '1.0835', 0, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('2.015556', '1.9956', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('partial repair guard 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('partial repair guard 2', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')],
 [('regression band-boundary 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('regression band-boundary 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('2.015556', '1.9956', 100, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression band-boundary 1', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('regression band-boundary 2', ('1.29844', '1.1804', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('1.886276', '1.8676', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.68751', '1.5341', 1000, False), 'accept'),
  ('partial repair guard 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('partial repair guard 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
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 band-boundary 1rejectacceptFailed
regression band-boundary 2rejectacceptFailed
partial repair guard 2rejectacceptFailed
control: lower boundaryrejectacceptFailed
control: drop too farrejectrejectPassed
control: inverted exactrejectacceptFailed
control: bad refERR:rateERR:ratePassed

SHA-256 / c42160cbac758f39f175c5b84d8fc7080a27351809ac038a6ba7e3e24dc6de6d

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(new, ref, tol_bps, inverted):
    n, r = Decimal(new), Decimal(ref)
    if r <= 0 or n <= 0: return 'ERR:rate'
    if inverted: n = 1 / n
    dev = abs(n - r) / r
    return 'accept' if dev * 10000 <= tol_bps else 'reject'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression band-boundary 1', ('1.1', '1.0', 1000, False), 'accept'),
  ('regression band-boundary 2', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('1.0835', '1.0835', 0, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('2.015556', '1.9956', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('partial repair guard 1', ('0.9', '1.0', 1000, False), 'accept'),
  ('partial repair guard 2', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')],
 [('regression band-boundary 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('regression band-boundary 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.9529160', '1.9432', 50, False), 'accept'),
  ('partial repair guard 2', ('2.015556', '1.9956', 100, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject'),
  ('control: upper boundary', ('1.1', '1.0', 1000, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept')],
 [('regression band-boundary 1', ('1.8098883', '1.8117', 10, False), 'accept'),
  ('regression band-boundary 2', ('1.29844', '1.1804', 1000, False), 'accept'),
  ('partial repair guard 1', ('1.610829', '1.6271', 100, False), 'accept'),
  ('partial repair guard 2', ('1.19829675', '1.2013', 25, False), 'accept'),
  ('control: lower boundary', ('0.9', '1.0', 1000, False), 'accept'),
  ('control: drop too far', ('0.8', '1.0', 1000, False), 'reject'),
  ('control: inverted exact', ('0.5', '2.0', 0, True), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate')],
 [('regression band-boundary 1', ('1.886276', '1.8676', 100, False), 'accept'),
  ('regression band-boundary 2', ('1.68751', '1.5341', 1000, False), 'accept'),
  ('partial repair guard 1', ('0.61172550', '0.6102', 25, False), 'accept'),
  ('partial repair guard 2', ('0.94611', '0.8601', 1000, False), 'accept'),
  ('control: bad ref', ('1.2', '0', 5, False), 'ERR:rate'),
  ('control: small move', ('1.08351', '1.0835', 1, False), 'accept'),
  ('control: rise too far', ('1.2', '1.0', 1000, False), 'reject'),
  ('control: inverted far', ('0.9', '1.0', 50, True), 'reject')]]
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 band-boundary 1acceptacceptPassed
regression band-boundary 2acceptacceptPassed
partial repair guard 2acceptacceptPassed
control: lower boundaryacceptacceptPassed
control: drop too farrejectrejectPassed
control: inverted exactacceptacceptPassed
control: bad refERR:rateERR:ratePassed

SHA-256 / 786527074e57835e40832c056218e73f14017e906c01f05070fe12ae37ea8f62

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

Case digest / f64c51c0dbd2baf3bff7bab3a5daf16c3ead33a10594b2fc30ad6675ac2e4ee1