fix(math): avoid overflow in Math.asinh for very large finite inputs#5241
Closed
Veercodeprog wants to merge 2 commits intoboa-dev:mainfrom
Closed
fix(math): avoid overflow in Math.asinh for very large finite inputs#5241Veercodeprog wants to merge 2 commits intoboa-dev:mainfrom
Veercodeprog wants to merge 2 commits intoboa-dev:mainfrom
Conversation
Member
|
Duplicate of #5240 |
Author
i havent checked the code of 5240 before i pushed my code , i just checked the review of the pr |
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 #5239
This Pull Request fixes/closes #5239.
It changes the following:
x, Rust’sf64::asinhcan overflow internally (e.g. when formingx²), soMath.asinhreturned±Infinityinstead of a finite value (e.g.1e308,Number.MAX_VALUE).|x|²would overflow, use the large-magnitude approximationsign(x) · (ln(2|x|) + 1/(4x²)), with the correction computed as(1/(2x))²sox²is never formed. Otherwise delegate tof64::asinh. Implemented incore/engine/src/builtins/math/mod.rs.asinhtests incore/engine/src/builtins/math/tests.rsfor1e308,Number.MAX_VALUE, and-1e308.How to verify
cargo test -p boa_engine builtins::math::tests::asinhcargo run --bin boa -- -e 'console.log(Math.asinh(1e308)); console.log(Math.asinh(Number.MAX_VALUE)); console.log(Math.asinh(-1e308))'— expect finite values (~709.89, ~710.48, ~-709.89), notInfinity.