FA-16931 / Floating-point arithmetic / Open access
Decimal fused multiply-add rounds inputs to working precision · case 01
Decimal fused multiply-add rounds inputs to working precision.
ROOT CAUSE
Decimal fused multiply-add rounds inputs to working precision. The faulty expression is av=ctx.create_decimal(a); bv=ctx.create_decimal(b); cv=ctx.create_decimal(c).
THE FAILURE
Decimal fused multiply-add rounds inputs to working precision. The faulty expression is av=ctx.create_decimal(a); bv=ctx.create_decimal(b); cv=ctx.create_decimal(c).
Unsuccessful approach: The attempted local correction av=Decimal(a); bv=Decimal(b); cv=ctx.create_decimal(c) still violates the explicit regression fixtures.
Case contract
Decimal fused multiply-add rounds a*b+c once in a fresh precision-limited half-even context. Inputs are decimal strings; return final decimal string and Inexact flag.
Why this case matters
An offline floating representation model isolates a reproducible arithmetic fault.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN
N = 1
observations = []
def solve(a,b,c,precision):
ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
for signal in ctx.traps: ctx.traps[signal]=False
av=ctx.create_decimal(a); bv=ctx.create_decimal(b); cv=ctx.create_decimal(c)
result=ctx.fma(av,bv,cv)
return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| cancellation | ['-0.0012', False] | ['-0.0012', False] | Passed |
| opposite cancellation | ['0.0012', False] | ['0.0012', False] | Passed |
| tiny addend | ['1.00', True] | ['1.00', True] | Passed |
| odd tie | ['1.02', True] | ['1.02', True] | Passed |
| variable exact | ['5', False] | ['5', False] | Passed |
| addend precision | ['0.00', True] | ['0.00001', False] | Failed |
| operand precision | ['1.23', True] | ['1.23', True] | Passed |
SHA-256 / a54a4ec73c9535e8fc708a0594e910966b66e738219c35c790f2cb1e1fa2b220
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import decimal
from decimal import Decimal, Context, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_DOWN
N = 1
observations = []
def solve(a,b,c,precision):
ctx=Context(prec=precision,rounding=ROUND_HALF_EVEN)
for signal in ctx.traps: ctx.traps[signal]=False
av=Decimal(a); bv=Decimal(b); cv=ctx.create_decimal(c)
result=ctx.fma(av,bv,cv)
return [str(result),ctx.flags[decimal.Inexact]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cancellation', solve("1.23","4.56","-5.61",3), ["-0.0012",False])
check('opposite cancellation', solve("-1.23","4.56","5.61",3), ["0.0012",False])
check('tiny addend', solve("1","1","0.005",3), ["1.00",True])
check('odd tie', solve("1","1","0.015",3), ["1.02",True])
check('variable exact', solve(str(N),"2","3",3), [str(2*N+3),False])
check('addend precision', solve("1.23456","1","-1.23455",3), ["0.00001",False])
check('operand precision', solve("1.23456","1","0",3), ["1.23",True])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| cancellation | ['-0.0012', False] | ['-0.0012', False] | Passed |
| opposite cancellation | ['0.0012', False] | ['0.0012', False] | Passed |
| tiny addend | ['1.00', True] | ['1.00', True] | Passed |
| odd tie | ['1.02', True] | ['1.02', True] | Passed |
| variable exact | ['5', False] | ['5', False] | Passed |
| addend precision | ['0.00456', True] | ['0.00001', False] | Failed |
| operand precision | ['1.23', True] | ['1.23', True] | Passed |
SHA-256 / b9e70590f9481e2a03b8751880e896101fccd0d46a63776f2036bf106e77135c
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:39:41.621633+00:00.
Case digest / ae7c09f0c7a589033d6af55712fd047edcf2aad1f2e4388eaf3cad7d3d297dab