Repository navigation
Conversation
Handle multiplication exponent underflow without discarding products that remain representable through their coefficients. Round directly to the destination precision using nearest, ties-to-even rounding, avoiding double rounding through an intermediate wide subnormal. Keep extendedMul's wider result and preserve signed zero on underflow. Preserve fitting subnormal coefficients during narrowing and limit widening normalization to the available exponent range. Use an unsigned distance from the exponent floor for the boundary check and correct the underflow shift direction. Add regressions for multiplication by one, representable squares, halfway rounding, signed zero, subnormal conversions, and a product that previously rounded twice. Fixes libmir#487. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Contributor
Author
|
Failing CircleCI is unrelated |
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.
Fixes #487.
Fpmultiplication currently discards a product when the sum of the operand exponents falls belowlong.min, even when the coefficient makes the result representable. This can turn multiplication by one into zero near the exponent floor.Handle these products by shifting and rounding the coefficient instead of immediately returning zero. Ordinary multiplication rounds directly to its destination precision, avoiding double rounding through an intermediate wide subnormal.
extendedMulretains its wider result, and genuine underflow preserves signed zero.The resulting subnormal values also need to survive conversions between
Fpwidths. Preserve coefficients that already fit when narrowing, and limit normalization when widening to the available exponent range.Regression coverage
Cover multiplication by one, representable squares, halfway rounding with ties to even, signed zero, widening and narrowing subnormals, and a concrete double-rounding counterexample.
Validation
AI-Assisted-By: Codex (GPT-6 Astra Medium)