Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion std/assembly/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,11 @@ export namespace NativeMath {

export function acosh(x: f64): f64 { // see: musl/src/math/acosh.c
const s = reinterpret<f64>(0x3FE62E42FEFA39EF);
var e = reinterpret<u64>(x) >> 52 & 0x7FF;
var u = reinterpret<u64>(x);
// Prevent propagation for all input values less than 1.0.
// Note musl lib didn't fix this yet.
if (<i64>u < 0x3FF0000000000000) return (x - x) / 0.0;
var e = u >> 52 & 0x7FF;
if (e < 0x3FF + 1) return log1p(x - 1 + builtin_sqrt<f64>((x - 1) * (x - 1) + 2 * (x - 1)));
if (e < 0x3FF + 26) return log(2 * x - 1 / (x + builtin_sqrt<f64>(x * x - 1)));
return log(x) + s;
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/std/array.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -4547,7 +4547,7 @@
if
i32.const 0
i32.const 7264
i32.const 1417
i32.const 1421
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/std/array.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -6650,7 +6650,7 @@
if
i32.const 0
i32.const 6240
i32.const 1417
i32.const 1421
i32.const 5
call $~lib/builtins/abort
unreachable
Expand Down
Loading