UNPKG

697 BJavaScriptView Raw
1var $ = require('../internals/export');
2var log1p = require('../internals/math-log1p');
3
4var nativeAcosh = Math.acosh;
5var log = Math.log;
6var sqrt = Math.sqrt;
7var LN2 = Math.LN2;
8
9var FORCED = !nativeAcosh
10 // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
11 || Math.floor(nativeAcosh(Number.MAX_VALUE)) != 710
12 // Tor Browser bug: Math.acosh(Infinity) -> NaN
13 || nativeAcosh(Infinity) != Infinity;
14
15// `Math.acosh` method
16// https://tc39.es/ecma262/#sec-math.acosh
17$({ target: 'Math', stat: true, forced: FORCED }, {
18 acosh: function acosh(x) {
19 return (x = +x) < 1 ? NaN : x > 94906265.62425156
20 ? log(x) + LN2
21 : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
22 }
23});