fix(math): correct Math.asinh for large finite inputs#5240
fix(math): correct Math.asinh for large finite inputs#5240HiteshShonak wants to merge 4 commits intoboa-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Math.asinh returning Infinity for very large finite inputs by introducing a large-input fallback formula consistent with common libm/Boost behavior, and adds regression tests to prevent recurrence.
Changes:
- Add a large-input threshold in
Math.asinhto computesign(x) * (ln(|x|) + LN_2)for large finitex, avoiding overflow inf64::asinh(). - Add regression tests for
Math.asinh(1e308),Math.asinh(-1e308), andMath.asinh(Number.MAX_VALUE).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/engine/src/builtins/math/mod.rs | Adds a large-input branch to keep Math.asinh finite for extremely large finite numbers. |
| core/engine/src/builtins/math/tests.rs | Adds regression coverage for large finite inputs that previously overflowed to infinities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5240 +/- ##
===========================================
+ Coverage 47.24% 59.83% +12.58%
===========================================
Files 476 582 +106
Lines 46892 63459 +16567
===========================================
+ Hits 22154 37968 +15814
- Misses 24738 25491 +753 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: José Julián Espina <jedel0124@gmail.com>
This Pull Request fixes/closes #5239.
It changes the following:
1/√f64::EPSILON(67_108_864.0), fall back ton.signum() * (n.abs().ln() + LN_2)instead of callingf64::asinh()directly, avoiding an internal overflow that producesInfinity. threshold follows the Boost math library convention.Math.asinh(1e308),Math.asinh(-1e308), andMath.asinh(Number.MAX_VALUE).Testing:
cargo test -p boa_engine math -- --nocaptureSpec reference: https://tc39.es/ecma262/#sec-math.asinh