FAILURE MAP
← Case archive

FA-021 / Numerics / Open access

A decimal halfway value rounds downward · case 01

A value specified as a decimal rounds below the required half-up result.

Verified by executionVariant 1 · 3 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Converting through binary floating point changes the value before rounding.

VERIFIED REPAIR

Parse the decimal string directly and apply the explicit half-up rule.

Unsuccessful approach: Converting a float to Decimal preserves the earlier representation error.

Case contract

Parse the decimal string directly and apply the explicit half-up rule.

Why this case matters

A compact reasoning and repair task with executable evidence.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_UP
N = 1
observations = []
def solve(value):
    return format(round(float(value), 2), '.2f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('decimal midpoint', solve('1.005'), '1.01')
check('another midpoint', solve('2.675'), '2.68')
check('whole value', solve(str(N)), f'{N}.00')
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 fixtureActualExpectedOutcome
decimal midpoint1.001.01Failed
another midpoint2.672.68Failed
whole value1.001.00Passed

SHA-256 / 5633b9f12e2a24bf8ec5fb4190f2634e040ca3a94ed3bb4391b14cf7736a8feb

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_UP
N = 1
observations = []
def solve(value):
    return str(Decimal(float(value)).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('decimal midpoint', solve('1.005'), '1.01')
check('another midpoint', solve('2.675'), '2.68')
check('whole value', solve(str(N)), f'{N}.00')
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 fixtureActualExpectedOutcome
decimal midpoint1.001.01Failed
another midpoint2.672.68Failed
whole value1.001.00Passed

SHA-256 / 7c693e18c17c163694f95707994f280f5266a6a3c1bd1aa99f6fb62397ea0faf

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_UP
N = 1
observations = []
def solve(value):
    return str(Decimal(value).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('decimal midpoint', solve('1.005'), '1.01')
check('another midpoint', solve('2.675'), '2.68')
check('whole value', solve(str(N)), f'{N}.00')
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 fixtureActualExpectedOutcome
decimal midpoint1.011.01Passed
another midpoint2.682.68Passed
whole value1.001.00Passed

SHA-256 / 29a9d25ae0a9505cdd0d574153dbe0a0c2e0d7e940cd070be0b6504b2a6301c6

Verification & scope

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:36:49.868832+00:00.

Case digest / 4841f5465756b6c2031f4d88cd0db40c73962807ec2e1f25caff6c106bdc4a7a