FA-15976 / Floating-point arithmetic / Open access
Rounding downward increments positive magnitudes · case 01
Rounding downward increments positive magnitudes.
ROOT CAUSE
Rounding downward increments positive magnitudes. The faulty expression is increment=inexact.
VERIFIED REPAIR
Apply the contract at this fault site using increment=sign<0 and inexact.
Unsuccessful approach: The attempted local correction increment=sign>0 and inexact still violates the explicit regression fixtures.
Case contract
Round a nonnegative integer significand q with guard, round and sticky bits. Modes are nearest-even, nearest-away, zero, up, down; sign is +1 or -1. Return rounded signed integer, inexact flag, and whether rounding incremented the magnitude.
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
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
inexact=bool(g or r or s)
if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
elif mode == 'nearest-away': increment=bool(g)
elif mode == 'up': increment=sign>0 and inexact
elif mode == 'down': increment=inexact
else: increment=False
value=sign*(q+int(increment))
return [value,inexact,bool(increment)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,False])
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 |
|---|---|---|---|
| tie even | [2, True, False] | [2, True, False] | Passed |
| tie odd | [4, True, True] | [4, True, True] | Passed |
| above tie sticky | [3, True, True] | [3, True, True] | Passed |
| above tie round | [3, True, True] | [3, True, True] | Passed |
| below half | [2, True, False] | [2, True, False] | Passed |
| nearest away | [-3, True, True] | [-3, True, True] | Passed |
| up positive | [2, True, True] | [2, True, True] | Passed |
| up negative | [-1, True, False] | [-1, True, False] | Passed |
| down negative | [-2, True, True] | [-2, True, True] | Passed |
| down positive | [2, True, True] | [1, True, False] | Failed |
| truncate | [-1, True, False] | [-1, True, False] | Passed |
| exact | [1, False, False] | [1, False, False] | Passed |
SHA-256 / f75c53f0643696d3b2c0d36c87c865bcbf3adb04eaaf7b179ac70d0716d800c5
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
inexact=bool(g or r or s)
if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
elif mode == 'nearest-away': increment=bool(g)
elif mode == 'up': increment=sign>0 and inexact
elif mode == 'down': increment=sign>0 and inexact
else: increment=False
value=sign*(q+int(increment))
return [value,inexact,bool(increment)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,False])
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 |
|---|---|---|---|
| tie even | [2, True, False] | [2, True, False] | Passed |
| tie odd | [4, True, True] | [4, True, True] | Passed |
| above tie sticky | [3, True, True] | [3, True, True] | Passed |
| above tie round | [3, True, True] | [3, True, True] | Passed |
| below half | [2, True, False] | [2, True, False] | Passed |
| nearest away | [-3, True, True] | [-3, True, True] | Passed |
| up positive | [2, True, True] | [2, True, True] | Passed |
| up negative | [-1, True, False] | [-1, True, False] | Passed |
| down negative | [-1, True, False] | [-2, True, True] | Failed |
| down positive | [2, True, True] | [1, True, False] | Failed |
| truncate | [-1, True, False] | [-1, True, False] | Passed |
| exact | [1, False, False] | [1, False, False] | Passed |
SHA-256 / 0073367d20e05b48dcf158142a1a956276ef3771b14a5ddaa1c5df77a4127f81
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(q,g,r,s,sign,mode):
inexact=bool(g or r or s)
if mode == 'nearest-even': increment=bool(g and (r or s or q%2))
elif mode == 'nearest-away': increment=bool(g)
elif mode == 'up': increment=sign>0 and inexact
elif mode == 'down': increment=sign<0 and inexact
else: increment=False
value=sign*(q+int(increment))
return [value,inexact,bool(increment)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie even', solve(2*N,1,0,0,1,"nearest-even"), [2*N,True,False])
check('tie odd', solve(2*N+1,1,0,0,1,"nearest-even"), [2*N+2,True,True])
check('above tie sticky', solve(2*N,1,0,1,1,"nearest-even"), [2*N+1,True,True])
check('above tie round', solve(2*N,1,1,0,1,"nearest-even"), [2*N+1,True,True])
check('below half', solve(2*N,0,1,1,1,"nearest-even"), [2*N,True,False])
check('nearest away', solve(2*N,1,0,0,-1,"nearest-away"), [-2*N-1,True,True])
check('up positive', solve(N,0,0,1,1,"up"), [N+1,True,True])
check('up negative', solve(N,1,1,1,-1,"up"), [-N,True,False])
check('down negative', solve(N,0,1,0,-1,"down"), [-N-1,True,True])
check('down positive', solve(N,1,1,1,1,"down"), [N,True,False])
check('truncate', solve(N,1,1,1,-1,"zero"), [-N,True,False])
check('exact', solve(N,0,0,0,1,"up"), [N,False,False])
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 |
|---|---|---|---|
| tie even | [2, True, False] | [2, True, False] | Passed |
| tie odd | [4, True, True] | [4, True, True] | Passed |
| above tie sticky | [3, True, True] | [3, True, True] | Passed |
| above tie round | [3, True, True] | [3, True, True] | Passed |
| below half | [2, True, False] | [2, True, False] | Passed |
| nearest away | [-3, True, True] | [-3, True, True] | Passed |
| up positive | [2, True, True] | [2, True, True] | Passed |
| up negative | [-1, True, False] | [-1, True, False] | Passed |
| down negative | [-2, True, True] | [-2, True, True] | Passed |
| down positive | [1, True, False] | [1, True, False] | Passed |
| truncate | [-1, True, False] | [-1, True, False] | Passed |
| exact | [1, False, False] | [1, False, False] | Passed |
SHA-256 / a5a73ab805edc4aec7482b1c8c458ae63df1e594277495dbf7311049afcbfc91
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:32.099287+00:00.
Case digest / a3e1c9c39a9338c6686f057f7f118e2ad06efde7908eaadd0ed84e406d0a1d6d