Apply RMS exponent without underflowing 2^exp first - #52
Merged
Merged
Conversation
swgiacomelli
marked this pull request as ready for review
August 25, 2026 22:10
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3c7fe15f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This was referenced Aug 25, 2026
2.0.powi(-1075) is zero even when (nf/df)*2^-1075 is the smallest subnormal. Apply MIN_POSITIVE in 1022-bit steps so a scaled sample just above 2^-1075 still publishes rms_lsb = 2^-1074. This is not MAX_ERR_LSB. Co-authored-by: Steven Giacomelli <swgiacomelli@users.noreply.github.com>
Multiplying by 2^-1022 first can make a still-normal significand subnormal and round again on the leftover exponent, turning a three-unit residual into four and the five-sample RMS into two minimum-subnormal units. Co-authored-by: Steven Giacomelli <swgiacomelli@users.noreply.github.com>
swgiacomelli
force-pushed
the
cursor/s4-rms-ldexp-03fb
branch
from
August 25, 2026 22:28
13b0fab to
798d19b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to merged #50. Rebased onto
epic/36-surfaces-bakeafter #51 (S5 emit).Codex P2 on
07c0575: when both BigInt limbs are truncated and the shift difference is-1075,2.0.powi(exp)underflows to 0 beforenf / dfcan lift the result into the representable subnormal range.A later P2 on that same helper: multiplying by
MIN_POSITIVEfirst can make a still-normal significand subnormal and round again on the leftover exponent.Ratio::to_f64applies2^expby taking the remainder while the significand is still normal, then multiplying by2^-1022once. That keeps a significand just above2^-1075asf64::from_bits(1), and converts the[0, 17]lerp residual to three minimum-subnormal units rather than four.Proof:
f64::from_bits(0x0c70_0000_0000_0001)at scalef64::from_bits(0x3040_0000_0000_0001)quantize to a zero 2×2,MAX_ERR_LSB = 1,rms_lsb = 2^-1074(not0)[0, 17], rows[0, 1]/[0, 1], off-knotx = f64::from_bits(0x0088_0000_0000_0000),y = 0.5,value = f64::from_bits(0x0046_9696_9696_9697): residual converts to three minimum-subnormal units,MAX_ERR_LSB = 1, five-samplerms_lsb = f64::from_bits(1)(not2)This is the operator RMS path, not the bound. This PR does not add S6–S7 work.
Verification
cargo xtask cion798d19b(full profile, not release): all runnable checks PASS; baker line budget 1725 / 1800. SKIP: secret scan (gitleaks not installed). A skip is not a pass. This is not release evidence.PR base is
epic/36-surfaces-bake.