FEATURE: Numeric Builtins
| Field | Value |
|---|---|
| Version | 20261028 V1 |
| Description | Implement jq math functions and non-decnum numeric behavior. |
| Depends On | FEATURE-Formats.md |
| Provides | jq numeric builtins |
| Consumes | jq format filters |
Purpose
Provide the math functions and numeric edge cases exercised by the jq 1.8.2 corpus, following the manual's non-decnum behavior.
Behavior
- Implement the corpus-required unary, binary, and ternary math functions with jq argument and generator semantics.
- Use IEEE double-precision behavior for arithmetic and comparisons, including infinities, NaN, signed values, and jq's serialization of special numeric values.
- Return false for
have_decnumand follow the corpus's non-decnum branch for parsing, conversion, rounding, and serialization. - Raise runtime errors where the manual and corpus require them; preserve output already generated.
Programmatic Acceptance
=== AC numeric-corpus ===
Intent: Numeric functions and the selected non-decnum cases execute with the corpus-defined results.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
Probe Count: summary
import json import os import subprocess import sys
SELECT = r"have_decnum|isnan|infinite|pow\(|\bfabs\b|\bsqrt\b|\bfloor\b" result = subprocess.run( [sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"], capture_output=True, text=True, env={**os.environ, "JQ": os.path.abspath("jq")}, ) print(result.stdout) print(result.stderr, file=sys.stderr) report = json.loads(result.stdout) tally = report["summary"] assert sum(tally.values()) > 0, f"selector matched no case: {SELECT}" assert tally["fail"] == 0 and tally["error"] == 0, tally assert result.returncode == 0, result.returncode === END AC numeric-corpus ===
User Acceptance
- None.
Guardrails
- Use only the Python standard library; do not invoke a system jq or third-party jq implementation.
- Do not alter staged source assets.