{"abstract":"-150 cents renders as '$-2.50'.","category":"Currency rounding and FX conversion","checks":7,"contract":"solve(minor, ccy): format integer minor units. Styles: USD '$' prefix, ',' groups, '.' decimal, 2 digits; EUR ' €' suffix, '.' groups, ',' decimal, 2; JPY '¥' prefix, ',' groups, 0 digits (no decimal separator); CHF 'CHF ' prefix, \"'\" groups, '.', 2; KWD 'KD ' prefix, ',', '.', 3. Group the whole part in threes from the right; the fraction is zero-padded to the exponent. A negative amount places '-' before everything. Unknown codes return 'ERR:currency'.","evaluation_group":"w2-currency_rounding_and_fx_conversion-currency-display-format","failed_approach":"Truncating division fixes the magnitude but takes the sign from the whole part, losing it for amounts under one unit.","family":"w2-currency_rounding_and_fx_conversion-currency-display-format-negative-divmod","id":"FA-62136","implementations":{"attempt":{"sha256":"e29ff863a1c150f56fbb26a2e12368c13eeadb03818689efd629f74de02d73c3","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(minor, ccy):\n    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', \"'\", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}\n    if ccy not in spec: return 'ERR:currency'\n    pre, suf, grp, dec, e = spec[ccy]\n    major, frac = int(minor / 10 ** e), abs(minor) % 10 ** e\n    neg = major < 0\n    digits = str(abs(major))\n    groups = []\n    while len(digits) > 3:\n        groups.insert(0, digits[-3:])\n        digits = digits[:-3]\n    groups.insert(0, digits)\n    body = grp.join(groups)\n    if e: body += dec + str(frac).zfill(e)\n    return ('-' if neg else '') + pre + body + suf\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression negative-divmod 1', (-150, 'USD'), '-$1.50'), ('regression negative-divmod 2', (-50, 'EUR'), '-0,50 €'),\n  ('partial repair guard 2', (-50, 'KWD'), '-KD 0.050'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005')],\n [('regression negative-divmod 1', (-50, 'KWD'), '-KD 0.050'),\n  ('regression negative-divmod 2', (-105, 'KWD'), '-KD 0.105'), ('partial repair guard 2', (-50, 'CHF'), '-CHF 0.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],\n [('regression negative-divmod 1', (-123456, 'EUR'), '-1.234,56 €'),\n  ('regression negative-divmod 2', (-987654321, 'USD'), '-$9,876,543.21'),\n  ('partial repair guard 1', (-5, 'CHF'), '-CHF 0.05'), ('partial repair guard 2', (-5, 'USD'), '-$0.05'),\n  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),\n  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],\n [('regression negative-divmod 1', (-99999, 'KWD'), '-KD 99.999'),\n  ('regression negative-divmod 2', (-99999, 'USD'), '-$999.99'), ('partial repair guard 1', (-5, 'KWD'), '-KD 0.005'),\n  ('partial repair guard 2', (-999, 'KWD'), '-KD 0.999'), ('control: small dollars', (105, 'USD'), '$1.05'),\n  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: negative dollars', (-150, 'USD'), '-$1.50')],\n [('regression negative-divmod 1', (-50, 'CHF'), '-CHF 0.50'),\n  ('regression negative-divmod 2', (-105, 'EUR'), '-1,05 €'), ('partial repair guard 1', (-50, 'USD'), '-$0.50'),\n  ('partial repair guard 2', (-5, 'EUR'), '-0,05 €'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),\n  ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),\n  ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\")]]\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":"9ba5a6f818121399872685883dace094987df1acf77c4e16fb5a281f8ceec74f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(minor, ccy):\n    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', \"'\", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}\n    if ccy not in spec: return 'ERR:currency'\n    pre, suf, grp, dec, e = spec[ccy]\n    neg = minor < 0\n    major, frac = divmod(minor, 10 ** e)\n    digits = str(abs(major))\n    groups = []\n    while len(digits) > 3:\n        groups.insert(0, digits[-3:])\n        digits = digits[:-3]\n    groups.insert(0, digits)\n    body = grp.join(groups)\n    if e: body += dec + str(frac).zfill(e)\n    return ('-' if neg else '') + pre + body + suf\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression negative-divmod 1', (-150, 'USD'), '-$1.50'), ('regression negative-divmod 2', (-50, 'EUR'), '-0,50 €'),\n  ('partial repair guard 2', (-50, 'KWD'), '-KD 0.050'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005')],\n [('regression negative-divmod 1', (-50, 'KWD'), '-KD 0.050'),\n  ('regression negative-divmod 2', (-105, 'KWD'), '-KD 0.105'), ('partial repair guard 2', (-50, 'CHF'), '-CHF 0.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],\n [('regression negative-divmod 1', (-123456, 'EUR'), '-1.234,56 €'),\n  ('regression negative-divmod 2', (-987654321, 'USD'), '-$9,876,543.21'),\n  ('partial repair guard 1', (-5, 'CHF'), '-CHF 0.05'), ('partial repair guard 2', (-5, 'USD'), '-$0.05'),\n  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),\n  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],\n [('regression negative-divmod 1', (-99999, 'KWD'), '-KD 99.999'),\n  ('regression negative-divmod 2', (-99999, 'USD'), '-$999.99'), ('partial repair guard 1', (-5, 'KWD'), '-KD 0.005'),\n  ('partial repair guard 2', (-999, 'KWD'), '-KD 0.999'), ('control: small dollars', (105, 'USD'), '$1.05'),\n  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: negative dollars', (-150, 'USD'), '-$1.50')],\n [('regression negative-divmod 1', (-50, 'CHF'), '-CHF 0.50'),\n  ('regression negative-divmod 2', (-105, 'EUR'), '-1,05 €'), ('partial repair guard 1', (-50, 'USD'), '-$0.50'),\n  ('partial repair guard 2', (-5, 'EUR'), '-0,05 €'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),\n  ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),\n  ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\")]]\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"},"fixed":{"sha256":"a51cbb174f08cfa32824a916e75511ce1401ae502336e5bcf2361411cca1f876","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(minor, ccy):\n    spec = {'USD': ('$', '', ',', '.', 2), 'EUR': ('', ' €', '.', ',', 2), 'JPY': ('¥', '', ',', '.', 0), 'CHF': ('CHF ', '', \"'\", '.', 2), 'KWD': ('KD ', '', ',', '.', 3)}\n    if ccy not in spec: return 'ERR:currency'\n    pre, suf, grp, dec, e = spec[ccy]\n    neg = minor < 0\n    major, frac = divmod(abs(minor), 10 ** e)\n    digits = str(major)\n    groups = []\n    while len(digits) > 3:\n        groups.insert(0, digits[-3:])\n        digits = digits[:-3]\n    groups.insert(0, digits)\n    body = grp.join(groups)\n    if e: body += dec + str(frac).zfill(e)\n    return ('-' if neg else '') + pre + body + suf\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression negative-divmod 1', (-150, 'USD'), '-$1.50'), ('regression negative-divmod 2', (-50, 'EUR'), '-0,50 €'),\n  ('partial repair guard 2', (-50, 'KWD'), '-KD 0.050'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005')],\n [('regression negative-divmod 1', (-50, 'KWD'), '-KD 0.050'),\n  ('regression negative-divmod 2', (-105, 'KWD'), '-KD 0.105'), ('partial repair guard 2', (-50, 'CHF'), '-CHF 0.50'),\n  ('control: yen', (1234567, 'JPY'), '¥1,234,567'), ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\"),\n  ('control: dinar', (1005, 'KWD'), 'KD 1.005'), ('control: unknown', (5, 'GBP'), 'ERR:currency')],\n [('regression negative-divmod 1', (-123456, 'EUR'), '-1.234,56 €'),\n  ('regression negative-divmod 2', (-987654321, 'USD'), '-$9,876,543.21'),\n  ('partial repair guard 1', (-5, 'CHF'), '-CHF 0.05'), ('partial repair guard 2', (-5, 'USD'), '-$0.05'),\n  ('control: unknown', (5, 'GBP'), 'ERR:currency'), ('control: million euros', (100000000, 'EUR'), '1.000.000,00 €'),\n  ('control: zero yen', (0, 'JPY'), '¥0'), ('control: small dollars', (105, 'USD'), '$1.05')],\n [('regression negative-divmod 1', (-99999, 'KWD'), '-KD 99.999'),\n  ('regression negative-divmod 2', (-99999, 'USD'), '-$999.99'), ('partial repair guard 1', (-5, 'KWD'), '-KD 0.005'),\n  ('partial repair guard 2', (-999, 'KWD'), '-KD 0.999'), ('control: small dollars', (105, 'USD'), '$1.05'),\n  ('control: negative yen', (-1000, 'JPY'), '-¥1,000'), ('control: dollars', (123450, 'USD'), '$1,234.50'),\n  ('control: negative dollars', (-150, 'USD'), '-$1.50')],\n [('regression negative-divmod 1', (-50, 'CHF'), '-CHF 0.50'),\n  ('regression negative-divmod 2', (-105, 'EUR'), '-1,05 €'), ('partial repair guard 1', (-50, 'USD'), '-$0.50'),\n  ('partial repair guard 2', (-5, 'EUR'), '-0,05 €'), ('control: negative dollars', (-150, 'USD'), '-$1.50'),\n  ('control: negative euro cents', (-50, 'EUR'), '-0,50 €'), ('control: yen', (1234567, 'JPY'), '¥1,234,567'),\n  ('control: franc', (12345678, 'CHF'), \"CHF 123'456.78\")]]\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-currency-display-format-negative-divmod","generated_at":"2026-09-29T14:47:01.782433+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.","repair":"Split the absolute amount and apply the sign separately.","root_cause":"divmod on the signed amount floors the whole part and yields a positive remainder.","sha256":"2a9ece40a7d7f517f81b218e7c8726d942a8bf923510172123df7879a89e2d86","title":"Negative minor amounts are split with floor division · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.348,"exit_code":1,"observations":[{"actual":"-$1.50","check":"regression negative-divmod 1","expected":"-$1.50","passed":true},{"actual":"0,50 €","check":"regression negative-divmod 2","expected":"-0,50 €","passed":false},{"actual":"KD 0.050","check":"partial repair guard 2","expected":"-KD 0.050","passed":false},{"actual":"$1,234.50","check":"control: dollars","expected":"$1,234.50","passed":true},{"actual":"¥1,234,567","check":"control: yen","expected":"¥1,234,567","passed":true},{"actual":"CHF 123'456.78","check":"control: franc","expected":"CHF 123'456.78","passed":true},{"actual":"KD 1.005","check":"control: dinar","expected":"KD 1.005","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression negative-divmod 1\", \"actual\": \"-$1.50\", \"expected\": \"-$1.50\", \"passed\": true}, {\"check\": \"regression negative-divmod 2\", \"actual\": \"0,50 €\", \"expected\": \"-0,50 €\", \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": \"KD 0.050\", \"expected\": \"-KD 0.050\", \"passed\": false}, {\"check\": \"control: dollars\", \"actual\": \"$1,234.50\", \"expected\": \"$1,234.50\", \"passed\": true}, {\"check\": \"control: yen\", \"actual\": \"¥1,234,567\", \"expected\": \"¥1,234,567\", \"passed\": true}, {\"check\": \"control: franc\", \"actual\": \"CHF 123'456.78\", \"expected\": \"CHF 123'456.78\", \"passed\": true}, {\"check\": \"control: dinar\", \"actual\": \"KD 1.005\", \"expected\": \"KD 1.005\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.778,"exit_code":1,"observations":[{"actual":"-$2.50","check":"regression negative-divmod 1","expected":"-$1.50","passed":false},{"actual":"-1,50 €","check":"regression negative-divmod 2","expected":"-0,50 €","passed":false},{"actual":"-KD 1.950","check":"partial repair guard 2","expected":"-KD 0.050","passed":false},{"actual":"$1,234.50","check":"control: dollars","expected":"$1,234.50","passed":true},{"actual":"¥1,234,567","check":"control: yen","expected":"¥1,234,567","passed":true},{"actual":"CHF 123'456.78","check":"control: franc","expected":"CHF 123'456.78","passed":true},{"actual":"KD 1.005","check":"control: dinar","expected":"KD 1.005","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression negative-divmod 1\", \"actual\": \"-$2.50\", \"expected\": \"-$1.50\", \"passed\": false}, {\"check\": \"regression negative-divmod 2\", \"actual\": \"-1,50 €\", \"expected\": \"-0,50 €\", \"passed\": false}, {\"check\": \"partial repair guard 2\", \"actual\": \"-KD 1.950\", \"expected\": \"-KD 0.050\", \"passed\": false}, {\"check\": \"control: dollars\", \"actual\": \"$1,234.50\", \"expected\": \"$1,234.50\", \"passed\": true}, {\"check\": \"control: yen\", \"actual\": \"¥1,234,567\", \"expected\": \"¥1,234,567\", \"passed\": true}, {\"check\": \"control: franc\", \"actual\": \"CHF 123'456.78\", \"expected\": \"CHF 123'456.78\", \"passed\": true}, {\"check\": \"control: dinar\", \"actual\": \"KD 1.005\", \"expected\": \"KD 1.005\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.206,"exit_code":0,"observations":[{"actual":"-$1.50","check":"regression negative-divmod 1","expected":"-$1.50","passed":true},{"actual":"-0,50 €","check":"regression negative-divmod 2","expected":"-0,50 €","passed":true},{"actual":"-KD 0.050","check":"partial repair guard 2","expected":"-KD 0.050","passed":true},{"actual":"$1,234.50","check":"control: dollars","expected":"$1,234.50","passed":true},{"actual":"¥1,234,567","check":"control: yen","expected":"¥1,234,567","passed":true},{"actual":"CHF 123'456.78","check":"control: franc","expected":"CHF 123'456.78","passed":true},{"actual":"KD 1.005","check":"control: dinar","expected":"KD 1.005","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression negative-divmod 1\", \"actual\": \"-$1.50\", \"expected\": \"-$1.50\", \"passed\": true}, {\"check\": \"regression negative-divmod 2\", \"actual\": \"-0,50 €\", \"expected\": \"-0,50 €\", \"passed\": true}, {\"check\": \"partial repair guard 2\", \"actual\": \"-KD 0.050\", \"expected\": \"-KD 0.050\", \"passed\": true}, {\"check\": \"control: dollars\", \"actual\": \"$1,234.50\", \"expected\": \"$1,234.50\", \"passed\": true}, {\"check\": \"control: yen\", \"actual\": \"¥1,234,567\", \"expected\": \"¥1,234,567\", \"passed\": true}, {\"check\": \"control: franc\", \"actual\": \"CHF 123'456.78\", \"expected\": \"CHF 123'456.78\", \"passed\": true}, {\"check\": \"control: dinar\", \"actual\": \"KD 1.005\", \"expected\": \"KD 1.005\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}