es.math.sinh.js 580 B

1234567891011121314151617181920
  1. var $ = require('../internals/export');
  2. var fails = require('../internals/fails');
  3. var expm1 = require('../internals/math-expm1');
  4. var abs = Math.abs;
  5. var exp = Math.exp;
  6. var E = Math.E;
  7. var FORCED = fails(function () {
  8. return Math.sinh(-2e-17) != -2e-17;
  9. });
  10. // `Math.sinh` method
  11. // https://tc39.github.io/ecma262/#sec-math.sinh
  12. // V8 near Chromium 38 has a problem with very small numbers
  13. $({ target: 'Math', stat: true, forced: FORCED }, {
  14. sinh: function sinh(x) {
  15. return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
  16. }
  17. });