{"abstract":"A refund of -0.004 USD is rendered as '-0.00'.","category":"Currency rounding and FX conversion","checks":6,"contract":"solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.","contract_signature":"amount, ccy","evaluation_group":"w2-currency_rounding_and_fx_conversion-minor-unit-quantize","failed_approach":"Replacing signed zero by Decimal(0) drops the sign but also discards the currency exponent, printing '0'.","family":"w2-currency_rounding_and_fx_conversion-minor-unit-quantize-signed-zero","id":"FA-61851","implementations":{"attempt":{"sha256":"b8ffd63c30e8e844556a3badbac138166bd010113250e61eb50cf7f0b043a258","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, ccy):\n    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}\n    code = ccy.strip().upper()\n    if code not in exps: return 'ERR:unknown-currency'\n    e = exps[code]\n    x = Decimal(amount)\n    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)\n    if q == 0 and q.is_signed(): q = Decimal(0)\n    return format(q, 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),\n  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),\n  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000')]]\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":"9f33ab88d166498f2e228dadaf5b695e303d8ecad605a0539bdadaa93b7538b9","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, ccy):\n    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}\n    code = ccy.strip().upper()\n    if code not in exps: return 'ERR:unknown-currency'\n    e = exps[code]\n    x = Decimal(amount)\n    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)\n    q = q\n    return format(q, 'f')\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000'),\n  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),\n  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),\n  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],\n [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),\n  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),\n  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),\n  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000')]]\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-quantize-signed-zero","generated_at":"2026-09-29T14:46:59.085140+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 quantized Decimal keeps its negative sign when the value rounds to zero.","sha256":"0b3079040ab0beff3697df2fe591508fae12df5c0b84a2a2a61224fa34992b0a","title":"A negative amount that rounds to zero prints as minus zero · 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":41.821,"exit_code":1,"observations":[{"actual":"0","check":"regression signed-zero 1","expected":"0.00","passed":false},{"actual":"0","check":"regression signed-zero 2","expected":"0","passed":true},{"actual":"2.66","check":"control: cents tie to even","expected":"2.66","passed":true},{"actual":"1236","check":"control: yen tie","expected":"1236","passed":true},{"actual":"10.000","check":"control: dinar three places","expected":"10.000","passed":true},{"actual":"1.2346","check":"control: unit of account four places","expected":"1.2346","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression signed-zero 1\", \"actual\": \"0\", \"expected\": \"0.00\", \"passed\": false}, {\"check\": \"regression signed-zero 2\", \"actual\": \"0\", \"expected\": \"0\", \"passed\": true}, {\"check\": \"control: cents tie to even\", \"actual\": \"2.66\", \"expected\": \"2.66\", \"passed\": true}, {\"check\": \"control: yen tie\", \"actual\": \"1236\", \"expected\": \"1236\", \"passed\": true}, {\"check\": \"control: dinar three places\", \"actual\": \"10.000\", \"expected\": \"10.000\", \"passed\": true}, {\"check\": \"control: unit of account four places\", \"actual\": \"1.2346\", \"expected\": \"1.2346\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.576,"exit_code":1,"observations":[{"actual":"-0.00","check":"regression signed-zero 1","expected":"0.00","passed":false},{"actual":"-0","check":"regression signed-zero 2","expected":"0","passed":false},{"actual":"2.66","check":"control: cents tie to even","expected":"2.66","passed":true},{"actual":"1236","check":"control: yen tie","expected":"1236","passed":true},{"actual":"10.000","check":"control: dinar three places","expected":"10.000","passed":true},{"actual":"1.2346","check":"control: unit of account four places","expected":"1.2346","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression signed-zero 1\", \"actual\": \"-0.00\", \"expected\": \"0.00\", \"passed\": false}, {\"check\": \"regression signed-zero 2\", \"actual\": \"-0\", \"expected\": \"0\", \"passed\": false}, {\"check\": \"control: cents tie to even\", \"actual\": \"2.66\", \"expected\": \"2.66\", \"passed\": true}, {\"check\": \"control: yen tie\", \"actual\": \"1236\", \"expected\": \"1236\", \"passed\": true}, {\"check\": \"control: dinar three places\", \"actual\": \"10.000\", \"expected\": \"10.000\", \"passed\": true}, {\"check\": \"control: unit of account four places\", \"actual\": \"1.2346\", \"expected\": \"1.2346\", \"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."}}