FA-16771 / Floating-point arithmetic / Open access
Sine-pi assigns the wrong sign to a negative half integer · case 01
Sine-pi assigns the wrong sign to a negative half integer.
ROOT CAUSE
Sine-pi assigns the wrong sign to a negative half integer. The faulty expression is if r==-0.5: return '1'.
THE FAILURE
Sine-pi assigns the wrong sign to a negative half integer. The faulty expression is if r==-0.5: return '1'.
Unsuccessful approach: The attempted local correction if r==-0.5: return '0' still violates the explicit regression fixtures.
Case contract
Evaluate sin(pi*x) for finite x using modulo-two reduction, with exact integer zeros carrying the sign of x and exact half-integer extrema. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.
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 struct
def render(x):
if math.isnan(x): return 'nan'
if math.isinf(x): return '-infinity' if x<0 else '+infinity'
return format(x,'.11g')
N = 1
observations = []
def solve(x):
try:
r=math.remainder(x,2.0)
if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
if r==0.5: return '1'
if r==-0.5: return '1'
if r>0.5: r=1-r
elif r < -0.5: r=-1-r
return render(math.sin(math.pi*r))
except (ValueError, OverflowError, ZeroDivisionError, TypeError):
return "arithmetic-error"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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 |
|---|---|---|---|
| remainder sign reversal | 0 | 0 | Passed |
| positive integer | 0 | 0 | Passed |
| negative integer | -0 | -0 | Passed |
| half positive | 1 | 1 | Passed |
| half negative | 1 | -1 | Failed |
| quarter | 0.70710678119 | 0.70710678119 | Passed |
| three quarters | 0.70710678119 | 0.70710678119 | Passed |
| negative three quarters | -0.70710678119 | -0.70710678119 | Passed |
| large integer | 0 | 0 | Passed |
| negative zero | -0 | -0 | Passed |
| near integer | 2.8572618736e-12 | 2.8572618736e-12 | Passed |
SHA-256 / 5a80cd1292db91ae3b903c73b3b791b3c027255ae993f383c7fa3dabbe58384a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
if math.isnan(x): return 'nan'
if math.isinf(x): return '-infinity' if x<0 else '+infinity'
return format(x,'.11g')
N = 1
observations = []
def solve(x):
try:
r=math.remainder(x,2.0)
if r==0 or abs(r)==1: return render(math.copysign(0.0,x))
if r==0.5: return '1'
if r==-0.5: return '0'
if r>0.5: r=1-r
elif r < -0.5: r=-1-r
return render(math.sin(math.pi*r))
except (ValueError, OverflowError, ZeroDivisionError, TypeError):
return "arithmetic-error"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remainder sign reversal', solve(3.0), "0")
check('positive integer', solve(float(N)), "0")
check('negative integer', solve(-float(N)), "-0")
check('half positive', solve(2.0*N+0.5), "1")
check('half negative', solve(-2.0*N-0.5), "-1")
check('quarter', solve(2.0*N+0.25), render(math.sqrt(0.5)))
check('three quarters', solve(2.0*N+0.75), render(math.sqrt(0.5)))
check('negative three quarters', solve(-2.0*N-0.75), render(-math.sqrt(0.5)))
check('large integer', solve(2.0**52+N), "0")
check('negative zero', solve(-0.0), "-0")
check('near integer', solve(1.0-2.0**-40), render(math.sin(math.pi*2.0**-40)))
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 |
|---|---|---|---|
| remainder sign reversal | 0 | 0 | Passed |
| positive integer | 0 | 0 | Passed |
| negative integer | -0 | -0 | Passed |
| half positive | 1 | 1 | Passed |
| half negative | 0 | -1 | Failed |
| quarter | 0.70710678119 | 0.70710678119 | Passed |
| three quarters | 0.70710678119 | 0.70710678119 | Passed |
| negative three quarters | -0.70710678119 | -0.70710678119 | Passed |
| large integer | 0 | 0 | Passed |
| negative zero | -0 | -0 | Passed |
| near integer | 2.8572618736e-12 | 2.8572618736e-12 | Passed |
SHA-256 / 6e323a3f148096a063b8e2d0dd7c14308937bfd187034f6bb8cab40233d87b8f
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 11 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:39.513670+00:00.
Case digest / 10030b29709a5c59996735c55718987ad381c1689980ce2079bfbc199effe150