{"abstract":"Large conversions at five- or six-decimal rates are off by many minor units.","category":"Currency rounding and FX conversion","checks":7,"contract":"solve(amount_minor, from_exp, to_exp, rate): amount_minor is an integer count of source minor units, rate a decimal string giving target major units per source major unit. The target minor amount is amount_minor * rate * 10**(to_exp - from_exp), computed exactly and rounded half-even to an integer.","contract_signature":"amount_minor, from_exp, to_exp, rate","evaluation_group":"w2-currency_rounding_and_fx_conversion-minor-unit-integer-conversion","failed_approach":"Keeping six decimals still loses precision for rates quoted with more digits.","family":"w2-currency_rounding_and_fx_conversion-minor-unit-integer-conversion-rate-storage-scale","id":"FA-62001","implementations":{"attempt":{"sha256":"a6f9f68d06532fdf449233f064a88979b65438fea7a83414f1b6f70436e12857","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(amount_minor, from_exp, to_exp, rate):\n    scale = Decimal(10) ** (to_exp - from_exp)\n    v = Decimal(amount_minor) * Decimal(rate).quantize(Decimal('0.000001'), rounding=ROUND_HALF_EVEN) * scale\n    return int(v.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression rate-storage-scale 1', (987654321, 2, 3, '0.30712'), 3033283951),\n  ('regression rate-storage-scale 2', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88),\n  ('control: cents to yen', (1000, 2, 0, '151.37'), 1514), ('control: float trap tie', (115, 2, 2, '1.1'), 126),\n  ('control: negative exact', (-250, 2, 2, '0.5'), -125), ('control: yen to dinar', (1, 0, 3, '0.3071'), 307)],\n [('regression rate-storage-scale 1', (123456789, 2, 2, '0.00000071'), 88),\n  ('regression rate-storage-scale 2', (123456, 2, 2, '1.08347'), 133761),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: negative tie', (-3, 2, 2, '0.5'), -2),\n  ('control: zero', (0, 2, 0, '151.37'), 0), ('control: large', (987654321, 2, 3, '0.30712'), 3033283951)],\n [('regression rate-storage-scale 1', (755323, 2, 4, '7.24667'), 547357652),\n  ('regression rate-storage-scale 2', (410259, 2, 2, '0.258909'), 106220),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88),\n  ('control: precise rate', (123456, 2, 2, '1.08347'), 133761),\n  ('control: large', (987654321, 2, 3, '0.30712'), 3033283951), ('control: cents to yen', (1000, 2, 0, '151.37'), 1514),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126)],\n [('regression rate-storage-scale 1', (286850, 2, 3, '1.495849'), 4290843),\n  ('regression rate-storage-scale 2', (253357, 0, 4, '18.88901'), 47856629066),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88), ('control: float trap tie', (115, 2, 2, '1.1'), 126),\n  ('control: negative exact', (-250, 2, 2, '0.5'), -125), ('control: yen to dinar', (1, 0, 3, '0.3071'), 307),\n  ('control: negative tie', (-3, 2, 2, '0.5'), -2)],\n [('regression rate-storage-scale 1', (395121, 3, 4, '1.362591'), 5383883),\n  ('regression rate-storage-scale 2', (402529, 2, 4, '1.969810'), 79290565),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88), ('control: negative tie', (-3, 2, 2, '0.5'), -2),\n  ('control: zero', (0, 2, 0, '151.37'), 0), ('control: precise rate', (123456, 2, 2, '1.08347'), 133761),\n  ('control: large', (987654321, 2, 3, '0.30712'), 3033283951)]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"ce75efaf5ae2086e436a90eeb4d1e5071c4157b26930119d27f129023e4c4974","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN\nN = 1\nobservations = []\ndef solve(amount_minor, from_exp, to_exp, rate):\n    scale = Decimal(10) ** (to_exp - from_exp)\n    v = Decimal(amount_minor) * Decimal(rate).quantize(Decimal('0.0001'), rounding=ROUND_HALF_EVEN) * scale\n    return int(v.quantize(Decimal(1), rounding=ROUND_HALF_EVEN))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression rate-storage-scale 1', (987654321, 2, 3, '0.30712'), 3033283951),\n  ('regression rate-storage-scale 2', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88),\n  ('control: cents to yen', (1000, 2, 0, '151.37'), 1514), ('control: float trap tie', (115, 2, 2, '1.1'), 126),\n  ('control: negative exact', (-250, 2, 2, '0.5'), -125), ('control: yen to dinar', (1, 0, 3, '0.3071'), 307)],\n [('regression rate-storage-scale 1', (123456789, 2, 2, '0.00000071'), 88),\n  ('regression rate-storage-scale 2', (123456, 2, 2, '1.08347'), 133761),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: negative tie', (-3, 2, 2, '0.5'), -2),\n  ('control: zero', (0, 2, 0, '151.37'), 0), ('control: large', (987654321, 2, 3, '0.30712'), 3033283951)],\n [('regression rate-storage-scale 1', (755323, 2, 4, '7.24667'), 547357652),\n  ('regression rate-storage-scale 2', (410259, 2, 2, '0.258909'), 106220),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88),\n  ('control: precise rate', (123456, 2, 2, '1.08347'), 133761),\n  ('control: large', (987654321, 2, 3, '0.30712'), 3033283951), ('control: cents to yen', (1000, 2, 0, '151.37'), 1514),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126)],\n [('regression rate-storage-scale 1', (286850, 2, 3, '1.495849'), 4290843),\n  ('regression rate-storage-scale 2', (253357, 0, 4, '18.88901'), 47856629066),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88), ('control: float trap tie', (115, 2, 2, '1.1'), 126),\n  ('control: negative exact', (-250, 2, 2, '0.5'), -125), ('control: yen to dinar', (1, 0, 3, '0.3071'), 307),\n  ('control: negative tie', (-3, 2, 2, '0.5'), -2)],\n [('regression rate-storage-scale 1', (395121, 3, 4, '1.362591'), 5383883),\n  ('regression rate-storage-scale 2', (402529, 2, 4, '1.969810'), 79290565),\n  ('partial repair guard 1', (100000000, 2, 2, '1.0834712'), 108347120),\n  ('partial repair guard 2', (123456789, 2, 2, '0.00000071'), 88), ('control: negative tie', (-3, 2, 2, '0.5'), -2),\n  ('control: zero', (0, 2, 0, '151.37'), 0), ('control: precise rate', (123456, 2, 2, '1.08347'), 133761),\n  ('control: large', (987654321, 2, 3, '0.30712'), 3033283951)]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-currency_rounding_and_fx_conversion-minor-unit-integer-conversion-rate-storage-scale","generated_at":"2026-09-29T14:47:00.517591+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.","root_cause":"The rate is quantized to 0.0001 as if read from a NUMERIC(10,4) column.","sha256":"dd146751b531277e792ca44be9f7f72a86e5755203c2df4cf6ee6fb08c2365b0","title":"The conversion rate is rounded to four decimals before use · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.336,"exit_code":1,"observations":[{"actual":3033283951,"check":"regression rate-storage-scale 1","expected":3033283951,"passed":true},{"actual":108347100,"check":"regression rate-storage-scale 2","expected":108347120,"passed":false},{"actual":123,"check":"partial repair guard 2","expected":88,"passed":false},{"actual":1514,"check":"control: cents to yen","expected":1514,"passed":true},{"actual":126,"check":"control: float trap tie","expected":126,"passed":true},{"actual":-125,"check":"control: negative exact","expected":-125,"passed":true},{"actual":307,"check":"control: yen to dinar","expected":307,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression rate-storage-scale 1\", \"actual\": 3033283951, \"expected\": 3033283951, \"passed\": true}, {\"check\": \"regression rate-storage-scale 2\", \"actual\": 108347100, \"expected\": 108347120, \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": 123, \"expected\": 88, \"passed\": false}, {\"check\": \"control: cents to yen\", \"actual\": 1514, \"expected\": 1514, \"passed\": true}, {\"check\": \"control: float trap tie\", \"actual\": 126, \"expected\": 126, \"passed\": true}, {\"check\": \"control: negative exact\", \"actual\": -125, \"expected\": -125, \"passed\": true}, {\"check\": \"control: yen to dinar\", \"actual\": 307, \"expected\": 307, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.352,"exit_code":1,"observations":[{"actual":3033086420,"check":"regression rate-storage-scale 1","expected":3033283951,"passed":false},{"actual":108350000,"check":"regression rate-storage-scale 2","expected":108347120,"passed":false},{"actual":0,"check":"partial repair guard 2","expected":88,"passed":false},{"actual":1514,"check":"control: cents to yen","expected":1514,"passed":true},{"actual":126,"check":"control: float trap tie","expected":126,"passed":true},{"actual":-125,"check":"control: negative exact","expected":-125,"passed":true},{"actual":307,"check":"control: yen to dinar","expected":307,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression rate-storage-scale 1\", \"actual\": 3033086420, \"expected\": 3033283951, \"passed\": false}, {\"check\": \"regression rate-storage-scale 2\", \"actual\": 108350000, \"expected\": 108347120, \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": 0, \"expected\": 88, \"passed\": false}, {\"check\": \"control: cents to yen\", \"actual\": 1514, \"expected\": 1514, \"passed\": true}, {\"check\": \"control: float trap tie\", \"actual\": 126, \"expected\": 126, \"passed\": true}, {\"check\": \"control: negative exact\", \"actual\": -125, \"expected\": -125, \"passed\": true}, {\"check\": \"control: yen to dinar\", \"actual\": 307, \"expected\": 307, \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}