fix(math): fix double rounding in Math.f16round#5238
Draft
ParthMozarkar wants to merge 2 commits intoboa-dev:mainfrom
Draft
fix(math): fix double rounding in Math.f16round#5238ParthMozarkar wants to merge 2 commits intoboa-dev:mainfrom
ParthMozarkar wants to merge 2 commits intoboa-dev:mainfrom
Conversation
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5238 +/- ##
===========================================
+ Coverage 47.24% 59.88% +12.64%
===========================================
Files 476 582 +106
Lines 46892 63460 +16568
===========================================
+ Hits 22154 38006 +15852
- Misses 24738 25454 +716 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Hey! I noticed Math.f16round was failing the test262 value-conversion.js
test and dug into why.
The issue is that the float16 crate's from_f64 converts through f32
internally, which causes double rounding for certain values.
For example Math.f16round(1.00048828125000022204) was returning 1
instead of the correct 1.0009765625.
I fixed it by switching to the half crate's f16::from_f64 which is
already in the dependency tree and converts directly from f64 to f16
without any intermediate f32 conversion.
All existing tests pass.
Fixes #5237