{"abstract":"Decimal quantization mistakes an exact subnormal for underflow.","category":"Floating-point arithmetic","checks":11,"contract":"Quantize a decimal text to 10**exponent using a fresh precision-limited decimal context, half-even rounding, Emin=-9 and Emax=9. All traps are disabled; return result string and raised flag names. The coefficient precision includes trailing zeros imposed by the target quantum.","evaluation_group":"s3-float-decimal-quantum","failed_approach":"The attempted local correction flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised and signal is not decimal.Subnormal) still violates the explicit regression fixtures.","family":"s3-floating_point_arithmetic-decimal-quantum-flag-subnormal","id":"FA-16916","implementations":{"attempt":{"sha256":"98776c898ce7ca5c6a66818c4dcedca1dc1e88ae3ee425f794387a04f36060e4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport decimal\nfrom decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN\n\nN = 1\nobservations = []\ndef solve(text, exponent, precision):\n    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)\n    for signal in ctx.traps: ctx.traps[signal]=False\n    ctx.clear_flags()\n    value=Decimal(text)\n    quantum=Decimal((0,(1,),exponent))\n    result=ctx.quantize(value,quantum)\n    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised and signal is not decimal.Subnormal)\n    return [str(result),flags]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie odd', solve(str(N)+\".255\",-2,6), [str(N)+\".26\",[\"Inexact\",\"Rounded\"]])\ncheck('tie even', solve(str(N)+\".245\",-2,6), [str(N)+\".24\",[\"Inexact\",\"Rounded\"]])\ncheck('rounded exact', solve(str(N)+\".200\",-2,6), [str(N)+\".20\",[\"Rounded\"]])\ncheck('already exact', solve(str(N)+\".20\",-2,6), [str(N)+\".20\",[]])\ncheck('one excess digit', solve(\"123.45\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('coefficient too large', solve(\"12345.67\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('subnormal exact', solve(\"1e-10\",-10,6), [\"1E-10\",[\"Subnormal\"]])\ncheck('negative zero', solve(\"-0.004\",-2,6), [\"-0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('positive zero', solve(\"0.004\",-2,6), [\"0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('integer quantum', solve(\"123.4\",1,6), [\"1.2E+2\",[\"Inexact\",\"Rounded\"]])\ncheck('overflow exponent', solve(\"1e10\",0,6), [\"NaN\",[\"InvalidOperation\"]])\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":"c2002b8b5a69be0af2c4190a039e28e5866c3cc85d3f30541f976f3eca191d5a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport decimal\nfrom decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN\n\nN = 1\nobservations = []\ndef solve(text, exponent, precision):\n    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)\n    for signal in ctx.traps: ctx.traps[signal]=False\n    ctx.clear_flags()\n    value=Decimal(text)\n    quantum=Decimal((0,(1,),exponent))\n    result=ctx.quantize(value,quantum)\n    flags=sorted(\"Underflow\" if signal is decimal.Subnormal else signal.__name__ for signal,raised in ctx.flags.items() if raised)\n    return [str(result),flags]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie odd', solve(str(N)+\".255\",-2,6), [str(N)+\".26\",[\"Inexact\",\"Rounded\"]])\ncheck('tie even', solve(str(N)+\".245\",-2,6), [str(N)+\".24\",[\"Inexact\",\"Rounded\"]])\ncheck('rounded exact', solve(str(N)+\".200\",-2,6), [str(N)+\".20\",[\"Rounded\"]])\ncheck('already exact', solve(str(N)+\".20\",-2,6), [str(N)+\".20\",[]])\ncheck('one excess digit', solve(\"123.45\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('coefficient too large', solve(\"12345.67\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('subnormal exact', solve(\"1e-10\",-10,6), [\"1E-10\",[\"Subnormal\"]])\ncheck('negative zero', solve(\"-0.004\",-2,6), [\"-0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('positive zero', solve(\"0.004\",-2,6), [\"0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('integer quantum', solve(\"123.4\",1,6), [\"1.2E+2\",[\"Inexact\",\"Rounded\"]])\ncheck('overflow exponent', solve(\"1e10\",0,6), [\"NaN\",[\"InvalidOperation\"]])\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":"460468a042fcf6d67d4cb763ba48f3f98f817466899bf87246a676393d0e8269","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport decimal\nfrom decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN\n\nN = 1\nobservations = []\ndef solve(text, exponent, precision):\n    ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN,Emin=-9,Emax=9)\n    for signal in ctx.traps: ctx.traps[signal]=False\n    ctx.clear_flags()\n    value=Decimal(text)\n    quantum=Decimal((0,(1,),exponent))\n    result=ctx.quantize(value,quantum)\n    flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised)\n    return [str(result),flags]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie odd', solve(str(N)+\".255\",-2,6), [str(N)+\".26\",[\"Inexact\",\"Rounded\"]])\ncheck('tie even', solve(str(N)+\".245\",-2,6), [str(N)+\".24\",[\"Inexact\",\"Rounded\"]])\ncheck('rounded exact', solve(str(N)+\".200\",-2,6), [str(N)+\".20\",[\"Rounded\"]])\ncheck('already exact', solve(str(N)+\".20\",-2,6), [str(N)+\".20\",[]])\ncheck('one excess digit', solve(\"123.45\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('coefficient too large', solve(\"12345.67\",-2,4), [\"NaN\",[\"InvalidOperation\"]])\ncheck('subnormal exact', solve(\"1e-10\",-10,6), [\"1E-10\",[\"Subnormal\"]])\ncheck('negative zero', solve(\"-0.004\",-2,6), [\"-0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('positive zero', solve(\"0.004\",-2,6), [\"0.00\",[\"Inexact\",\"Rounded\"]])\ncheck('integer quantum', solve(\"123.4\",1,6), [\"1.2E+2\",[\"Inexact\",\"Rounded\"]])\ncheck('overflow exponent', solve(\"1e10\",0,6), [\"NaN\",[\"InvalidOperation\"]])\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":"Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. 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":"s3-floating_point_arithmetic-decimal-quantum-flag-subnormal","generated_at":"2026-09-29T14:39:41.072927+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"An offline floating representation model isolates a reproducible arithmetic fault.","repair":"Apply the contract at this fault site using flags=sorted(signal.__name__ for signal,raised in ctx.flags.items() if raised).","root_cause":"Decimal quantization mistakes an exact subnormal for underflow. The faulty expression is flags=sorted(\"Underflow\" if signal is decimal.Subnormal else signal.__name__ for signal,raised in ctx.flags.items() if raised).","sha256":"071fdb95ba71da840e6391daff92a1fc6ac73b2b2b97daf3f851d09f568bef11","title":"Decimal quantization mistakes an exact subnormal for underflow · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":43.692,"exit_code":1,"observations":[{"actual":["1.26",["Inexact","Rounded"]],"check":"tie odd","expected":["1.26",["Inexact","Rounded"]],"passed":true},{"actual":["1.24",["Inexact","Rounded"]],"check":"tie even","expected":["1.24",["Inexact","Rounded"]],"passed":true},{"actual":["1.20",["Rounded"]],"check":"rounded exact","expected":["1.20",["Rounded"]],"passed":true},{"actual":["1.20",[]],"check":"already exact","expected":["1.20",[]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"one excess digit","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"coefficient too large","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["1E-10",[]],"check":"subnormal exact","expected":["1E-10",["Subnormal"]],"passed":false},{"actual":["-0.00",["Inexact","Rounded"]],"check":"negative zero","expected":["-0.00",["Inexact","Rounded"]],"passed":true},{"actual":["0.00",["Inexact","Rounded"]],"check":"positive zero","expected":["0.00",["Inexact","Rounded"]],"passed":true},{"actual":["1.2E+2",["Inexact","Rounded"]],"check":"integer quantum","expected":["1.2E+2",["Inexact","Rounded"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"overflow exponent","expected":["NaN",["InvalidOperation"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie odd\", \"actual\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"tie even\", \"actual\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"rounded exact\", \"actual\": [\"1.20\", [\"Rounded\"]], \"expected\": [\"1.20\", [\"Rounded\"]], \"passed\": true}, {\"check\": \"already exact\", \"actual\": [\"1.20\", []], \"expected\": [\"1.20\", []], \"passed\": true}, {\"check\": \"one excess digit\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"coefficient too large\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"subnormal exact\", \"actual\": [\"1E-10\", []], \"expected\": [\"1E-10\", [\"Subnormal\"]], \"passed\": false}, {\"check\": \"negative zero\", \"actual\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"positive zero\", \"actual\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"integer quantum\", \"actual\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"overflow exponent\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.573,"exit_code":1,"observations":[{"actual":["1.26",["Inexact","Rounded"]],"check":"tie odd","expected":["1.26",["Inexact","Rounded"]],"passed":true},{"actual":["1.24",["Inexact","Rounded"]],"check":"tie even","expected":["1.24",["Inexact","Rounded"]],"passed":true},{"actual":["1.20",["Rounded"]],"check":"rounded exact","expected":["1.20",["Rounded"]],"passed":true},{"actual":["1.20",[]],"check":"already exact","expected":["1.20",[]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"one excess digit","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"coefficient too large","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["1E-10",["Underflow"]],"check":"subnormal exact","expected":["1E-10",["Subnormal"]],"passed":false},{"actual":["-0.00",["Inexact","Rounded"]],"check":"negative zero","expected":["-0.00",["Inexact","Rounded"]],"passed":true},{"actual":["0.00",["Inexact","Rounded"]],"check":"positive zero","expected":["0.00",["Inexact","Rounded"]],"passed":true},{"actual":["1.2E+2",["Inexact","Rounded"]],"check":"integer quantum","expected":["1.2E+2",["Inexact","Rounded"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"overflow exponent","expected":["NaN",["InvalidOperation"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie odd\", \"actual\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"tie even\", \"actual\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"rounded exact\", \"actual\": [\"1.20\", [\"Rounded\"]], \"expected\": [\"1.20\", [\"Rounded\"]], \"passed\": true}, {\"check\": \"already exact\", \"actual\": [\"1.20\", []], \"expected\": [\"1.20\", []], \"passed\": true}, {\"check\": \"one excess digit\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"coefficient too large\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"subnormal exact\", \"actual\": [\"1E-10\", [\"Underflow\"]], \"expected\": [\"1E-10\", [\"Subnormal\"]], \"passed\": false}, {\"check\": \"negative zero\", \"actual\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"positive zero\", \"actual\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"integer quantum\", \"actual\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"overflow exponent\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.195,"exit_code":0,"observations":[{"actual":["1.26",["Inexact","Rounded"]],"check":"tie odd","expected":["1.26",["Inexact","Rounded"]],"passed":true},{"actual":["1.24",["Inexact","Rounded"]],"check":"tie even","expected":["1.24",["Inexact","Rounded"]],"passed":true},{"actual":["1.20",["Rounded"]],"check":"rounded exact","expected":["1.20",["Rounded"]],"passed":true},{"actual":["1.20",[]],"check":"already exact","expected":["1.20",[]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"one excess digit","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"coefficient too large","expected":["NaN",["InvalidOperation"]],"passed":true},{"actual":["1E-10",["Subnormal"]],"check":"subnormal exact","expected":["1E-10",["Subnormal"]],"passed":true},{"actual":["-0.00",["Inexact","Rounded"]],"check":"negative zero","expected":["-0.00",["Inexact","Rounded"]],"passed":true},{"actual":["0.00",["Inexact","Rounded"]],"check":"positive zero","expected":["0.00",["Inexact","Rounded"]],"passed":true},{"actual":["1.2E+2",["Inexact","Rounded"]],"check":"integer quantum","expected":["1.2E+2",["Inexact","Rounded"]],"passed":true},{"actual":["NaN",["InvalidOperation"]],"check":"overflow exponent","expected":["NaN",["InvalidOperation"]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie odd\", \"actual\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.26\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"tie even\", \"actual\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.24\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"rounded exact\", \"actual\": [\"1.20\", [\"Rounded\"]], \"expected\": [\"1.20\", [\"Rounded\"]], \"passed\": true}, {\"check\": \"already exact\", \"actual\": [\"1.20\", []], \"expected\": [\"1.20\", []], \"passed\": true}, {\"check\": \"one excess digit\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"coefficient too large\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}, {\"check\": \"subnormal exact\", \"actual\": [\"1E-10\", [\"Subnormal\"]], \"expected\": [\"1E-10\", [\"Subnormal\"]], \"passed\": true}, {\"check\": \"negative zero\", \"actual\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"-0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"positive zero\", \"actual\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"0.00\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"integer quantum\", \"actual\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"expected\": [\"1.2E+2\", [\"Inexact\", \"Rounded\"]], \"passed\": true}, {\"check\": \"overflow exponent\", \"actual\": [\"NaN\", [\"InvalidOperation\"]], \"expected\": [\"NaN\", [\"InvalidOperation\"]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}