Skip to content

t27b: the comptime_float arithmetic of lower_float.rs moves to specs/tri/t27b/comptime_float.t27 (Closes #8244) - #8247

Merged
gHashTag merged 1 commit into
masterfrom
t27b/lower-float-q
Oct 9, 2026
Merged

gHashTag merged 1 commit into
masterfrom
t27b/lower-float-q

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Closes #8244. A port slice of #6198 (t27b written in t27); see #6063. It pays back hand-written lines under cli/t27b/, as the owner's rule asks (see #8227).

What

The comptime_float arithmetic in cli/t27b/src/lower_float.rs moves into specs/tri/t27b/comptime_float.t27. That is Big, round_bits, Q and their two unit tests: Zig's comptime_float as an IEEE binary128 value, with its decimal literals, + - * /, order, and rounding to f64 and f32.

  • t27c gen-rust generates gen/rust/tri/t27b/comptime_float.rs, which lower_float.rs mounts with #[path], as eval.rs mounts eval_arith.rs.
  • lower_float.rs keeps Q as a one-field wrapper around the generated Q128, with the same methods. No caller changes.
  • Hand-written lines under cli/t27b/: +24, -408, net -384. lower_float.rs goes from 578 lines to 194.

Where a fixed size changes nothing

The Rust Big was a Vec<u64> with no bound. The t27 Big is 640 32-bit limbs (20480 bits), with a count of the limbs in use. Each place where that matters is handled so the result stays the same correctly rounded value:

  • Addition of far-apart values. When the two tops are more than 230 bits apart, the smaller operand is only a sticky bit below the 113 kept bits; when the signs differ, one is also taken from the larger. This gives the same correctly rounded result the Rust got by aligning the two exactly.
  • Order. Two values compare by their top bits first, so no alignment is wider than 113 bits.
  • Division. One compare-and-subtract per quotient bit.
  • A literal's finiteness. The Rust asked str::parse::<f64>. The port decides it exactly against 2^1024 - 2^970, the least value an f64 parse takes to infinity.
  • New limit. A literal that would need more than 20480 bits is refused (TOO_LONG). That takes about 750 digits next to the 10^-5000 cut-off, or 2048 characters anywhere. No spec has one.

Evidence that nothing changed

  • Differential (t27c lab; a throwaway test, not committed). It ran master's hand-written Q against the generated one, comparing every result, internal value and refusal message: 0 differences. It covered:
    • 30000 random f64 values, a fifth of them subnormal or tiny;
    • 20000 chained + - * /, whose results fed back into the pool (49988 values, far outside the f64 range included), with cmp, to_f64, to_f32 and exact_f64 of both operands;
    • 20000 random i128 for from_int, plus its edges;
    • 26033 literals: random digits, points, separators and exponents, the 40-digit decimal forms of the pool's f64s, 800-digit expansions, and the shapes at every edge (hex, malformed, 1., 1.e5, exponents past i64, 2e308, both sides of 2^1024 - 2^970, 1e-4999, 1e-5000, 5e-324 and its halfway point).
  • The spec's own tests. Four tests carry the Rust tests over: the hardware oracle for + - * /, cmp and to_f32; literals rounding once; and the edges.
    • t27c test-report: 4/4, 0 vacuous.
    • t27b --check (aarch64, qemu): 4/4, 1688 runtime asserts.
  • cargo test --release -p t27b on the t27c lab: 137 passed on x86_64 and 157 on aarch64, 0 failed. The build has no warning from the generated module; the mount allows dead_code, unused_parens and unexpected_cfgs.
  • Seal. t27c seal --save, then --verify: all hashes MATCH.
  • Repo gates.
    • dupe_scan.py: ok, and --like finds nothing in the new spec written elsewhere.
    • check_assertionless_spec_tests.py: ok.
    • check_seal_coverage.py: OK.
  • Policy gates, with master's gen/c/policy/own_language.c:
    • check_budget() on git diff --numstat --no-renames: exit 0;
    • check_all() with master's foreign-exceptions.txt: exit 0.

Signed lane receipts (#7686)

Requested from the t27b lab for this head and for master ca9866b. The compare is added here when both are in. Expected: every existing lane neutral, and the new spec's lane only-head.

Ledger

One row is added: specs/tri/t27b/comptime_float.t27 passes. No other row moves.

Lines (git diff --numstat --no-renames origin/master...HEAD)

file kind added deleted
cli/t27b/src/lower_float.rs hand-written 24 408
specs/tri/t27b/comptime_float.t27 .t27 (code and 4 tests) 1082 0
gen/rust/tri/t27b/comptime_float.rs t27c gen-rust, not hand-edited 908 0
.trinity/seals/t27b_T27bComptimeFloat.json seal 27 0
docs/reports/t27b_expectations.json ledger 1 0
AGENTS.md t27b remainder line 4 1

wc -l, in AGENTS.md: cli/t27b/src/*.rs goes from 15264 to 14880 on master ca9866b; cli/t27b/tests/*.rs stays at 8274.

🤖 Generated with Claude Code

…tri/t27b/comptime_float.t27 (Closes #8244)

Big, round_bits and Q (Zig's comptime_float as an IEEE binary128 value: decimal literals, + - * /, order, and
rounding to f64 and f32) are now t27, generated by t27c gen-rust into gen/rust/tri/t27b/comptime_float.rs and mounted
with #[path]. lower_float.rs keeps Q as a one-field wrapper: -384 hand-written lines under cli/t27b/. A throwaway
differential test on the t27c lab found 0 differences between the hand-written Q and the generated one. See #6198.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) October 9, 2026 16:02
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-09 16:04:33 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 48
PRs with All Checks Green 2
READY 0
FAILING 48
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 48 + 0 + 0 = 48, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=557cd271f4e3 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit 0fca4bd into master Oct 9, 2026
35 of 37 checks passed
@gHashTag
gHashTag deleted the t27b/lower-float-q branch October 9, 2026 16:06
gHashTag added a commit that referenced this pull request Oct 9, 2026
…het is green again (Closes #8269) (#8277)

0fca4bd (#8247) declared `pub const Text = struct` in
specs/tri/t27b/comptime_float.t27 while specs/test_framework/core.t27
already declares `struct Text`, and `tri types ratchet` has failed on
master since ("ledger 85 name(s), observed 86, + Text NEW conflict").

The type is renamed LiteralText (8 lines), gen/rust/tri/t27b/comptime_float.rs
is regenerated with t27c gen-rust, and the seal re-saved with master's
t27c (4 of 4 tests pass). Checked on the t27c lab at 0f66f5d:
tri types ratchet "ledger 85 name(s), observed 85, RATCHET: CLEAN";
cargo check -p t27b finishes. No hand-written line changes.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27b: the comptime_float arithmetic of lower_float.rs (Big, round_bits, Q) moves to specs/tri/t27b/comptime_float.t27

2 participants