Repository navigation
fix(base): retain representable F32.hypot lengths - #1515
Merged
Lorenzobattistela merged 3 commits intoOct 12, 2026
Merged
Conversation
…inary lengths keep the plain formula's bits
Lorenzobattistela
approved these changes
Oct 12, 2026
Merged
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.
F32.hypotsquares both components before it takes a square root. Those squares can become infinity or zero even when the vector length is representable. For example,hypot(1e30, 0)returns infinity andhypot(1e-30, 0)returns zero.Take the absolute values, order them as
hiandlo, and computehi * sqrt(1 + (lo / hi)^2). Handle zero and infinity before division. The existing NaN result policy stays the same. The examples above return1e30and1e-30with this change.This change uses existing Base operations. It adds no compiler primitive, dependency, or effect. The parser and compiler token caps stay unchanged.
Add two regressions. The first checks axis lengths across the F32 exponent range, scaled 3-4-5 triangles, argument order, negative components, the largest finite value, subnormal values, signed zero, infinity, and NaN. The second checks parallel vector lengths with the GPU entry point.
Validation:
main. The repository gate passes 54/54.git diff --checkpasses.hypotfor F32-roundedMath.hypotreference is two units in the last place. The checks reject an output infinity for a finite reference and an output zero for a positive reference. This sample does not establish a universal error bound or correct rounding.-O0on macOS and Linux. Linux leak detection is enabled.CUDA and the repository cluster were not tested. The performance, proof, and release gates were not run. This patch makes no performance claim.