es.math.acosh.js 771 B

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