Commit 5b0f62a
authored
fix(math): correct Math.acosh for large finite inputs (boa-dev#5230)
This Pull Request fixes/closes boa-dev#5229.
It changes the following:
- When the input is finite and greater than `1/√f64::EPSILON`
(`67_108_864.0`), fall back to `n.ln() + LN_2` instead of calling
`f64::acosh()` directly, avoiding an internal `x²` overflow that
produces `Infinity`. Threshold follows the [Boost math library
convention](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/inv_hyper/acosh.html).
- Add regression tests for `Math.acosh(1e308)` and
`Math.acosh(Number.MAX_VALUE)`.
Testing:
```bash
cargo test -p boa_engine math -- --nocapture
```
Spec reference: https://tc39.es/ecma262/#sec-math.acosh1 parent 66a1cd2 commit 5b0f62a
2 files changed
+16
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
0 commit comments