{"abstract":"Converted amounts are systematically short by up to one minor unit, and negatives move toward zero.","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":"Adding one half before truncating rounds positive ties up and mishandles every negative amount.","family":"w2-currency_rounding_and_fx_conversion-minor-unit-integer-conversion-integer-rounding","id":"FA-61991","implementations":{"attempt":{"sha256":"56bd0c48637df1d27b0bfd28c41fdf43a48580d7112f659cc493045624ae118a","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) * scale\n    return int(v + Decimal('0.5'))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression integer-rounding 1', (1000, 2, 0, '151.37'), 1514),\n  ('regression integer-rounding 2', (-3, 2, 2, '0.5'), -2), ('partial repair guard 2', (-7, 2, 2, '0.3'), -2),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126), ('control: negative exact', (-250, 2, 2, '0.5'), -125),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: zero', (0, 2, 0, '151.37'), 0)],\n [('regression integer-rounding 1', (123456, 2, 2, '1.08347'), 133761),\n  ('regression integer-rounding 2', (987654321, 2, 3, '0.30712'), 3033283951),\n  ('partial repair guard 1', (115, 2, 2, '1.1'), 126), ('partial repair guard 2', (-250, 2, 2, '0.5'), -125),\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: cents to yen', (1000, 2, 0, '151.37'), 1514)],\n [('regression integer-rounding 1', (589334, 0, 0, '168.0593'), 99043060),\n  ('regression integer-rounding 2', (64824, 0, 2, '51.9345'), 336660203),\n  ('partial repair guard 1', (-66003, 3, 4, '7.30025'), -4818384),\n  ('partial repair guard 2', (-35317, 0, 3, '196135.8'), -6926928048600),\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 integer-rounding 1', (410259, 2, 2, '0.258909'), 106220),\n  ('regression integer-rounding 2', (286850, 2, 3, '1.495849'), 4290843),\n  ('partial repair guard 1', (-46763, 3, 2, '4592.5'), -21475908),\n  ('partial repair guard 2', (-35469, 3, 2, '139877.5'), -496131505),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126), ('control: negative exact', (-250, 2, 2, '0.5'), -125),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: negative tie', (-3, 2, 2, '0.5'), -2)],\n [('regression integer-rounding 1', (253357, 0, 4, '18.88901'), 47856629066),\n  ('regression integer-rounding 2', (402529, 2, 4, '1.969810'), 79290565),\n  ('partial repair guard 1', (-87559, 2, 2, '118188.8'), -10348493139),\n  ('partial repair guard 2', (260569, 0, 4, '19.56965'), 50992441308), ('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":"725a562826ded1ac3ffa0e842f4291b3ad19959ff65ff1913f3afa1d95d9acd1","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) * scale\n    return int(v)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression integer-rounding 1', (1000, 2, 0, '151.37'), 1514),\n  ('regression integer-rounding 2', (-3, 2, 2, '0.5'), -2), ('partial repair guard 2', (-7, 2, 2, '0.3'), -2),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126), ('control: negative exact', (-250, 2, 2, '0.5'), -125),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: zero', (0, 2, 0, '151.37'), 0)],\n [('regression integer-rounding 1', (123456, 2, 2, '1.08347'), 133761),\n  ('regression integer-rounding 2', (987654321, 2, 3, '0.30712'), 3033283951),\n  ('partial repair guard 1', (115, 2, 2, '1.1'), 126), ('partial repair guard 2', (-250, 2, 2, '0.5'), -125),\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: cents to yen', (1000, 2, 0, '151.37'), 1514)],\n [('regression integer-rounding 1', (589334, 0, 0, '168.0593'), 99043060),\n  ('regression integer-rounding 2', (64824, 0, 2, '51.9345'), 336660203),\n  ('partial repair guard 1', (-66003, 3, 4, '7.30025'), -4818384),\n  ('partial repair guard 2', (-35317, 0, 3, '196135.8'), -6926928048600),\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 integer-rounding 1', (410259, 2, 2, '0.258909'), 106220),\n  ('regression integer-rounding 2', (286850, 2, 3, '1.495849'), 4290843),\n  ('partial repair guard 1', (-46763, 3, 2, '4592.5'), -21475908),\n  ('partial repair guard 2', (-35469, 3, 2, '139877.5'), -496131505),\n  ('control: float trap tie', (115, 2, 2, '1.1'), 126), ('control: negative exact', (-250, 2, 2, '0.5'), -125),\n  ('control: yen to dinar', (1, 0, 3, '0.3071'), 307), ('control: negative tie', (-3, 2, 2, '0.5'), -2)],\n [('regression integer-rounding 1', (253357, 0, 4, '18.88901'), 47856629066),\n  ('regression integer-rounding 2', (402529, 2, 4, '1.969810'), 79290565),\n  ('partial repair guard 1', (-87559, 2, 2, '118188.8'), -10348493139),\n  ('partial repair guard 2', (260569, 0, 4, '19.56965'), 50992441308), ('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-integer-rounding","generated_at":"2026-09-29T14:47:00.425766+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":"int(v) truncates the exact product instead of rounding it.","sha256":"39c568c1b634c0c185868c9042a2a164aa3273ea77a5963277b959645902c170","title":"The converted minor amount is truncated by int() · 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":42.936,"exit_code":1,"observations":[{"actual":1514,"check":"regression integer-rounding 1","expected":1514,"passed":true},{"actual":-1,"check":"regression integer-rounding 2","expected":-2,"passed":false},{"actual":-1,"check":"partial repair guard 2","expected":-2,"passed":false},{"actual":127,"check":"control: float trap tie","expected":126,"passed":false},{"actual":-124,"check":"control: negative exact","expected":-125,"passed":false},{"actual":307,"check":"control: yen to dinar","expected":307,"passed":true},{"actual":0,"check":"control: zero","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression integer-rounding 1\", \"actual\": 1514, \"expected\": 1514, \"passed\": true}, {\"check\": \"regression integer-rounding 2\", \"actual\": -1, \"expected\": -2, \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": -1, \"expected\": -2, \"passed\": false}, {\"check\": \"control: float trap tie\", \"actual\": 127, \"expected\": 126, \"passed\": false}, {\"check\": \"control: negative exact\", \"actual\": -124, \"expected\": -125, \"passed\": false}, {\"check\": \"control: yen to dinar\", \"actual\": 307, \"expected\": 307, \"passed\": true}, {\"check\": \"control: zero\", \"actual\": 0, \"expected\": 0, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.931,"exit_code":1,"observations":[{"actual":1513,"check":"regression integer-rounding 1","expected":1514,"passed":false},{"actual":-1,"check":"regression integer-rounding 2","expected":-2,"passed":false},{"actual":-2,"check":"partial repair guard 2","expected":-2,"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},{"actual":0,"check":"control: zero","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression integer-rounding 1\", \"actual\": 1513, \"expected\": 1514, \"passed\": false}, {\"check\": \"regression integer-rounding 2\", \"actual\": -1, \"expected\": -2, \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": -2, \"expected\": -2, \"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}, {\"check\": \"control: zero\", \"actual\": 0, \"expected\": 0, \"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."}}