es6.math.tanh.js 320 B

123456789101112
  1. // 20.2.2.33 Math.tanh(x)
  2. var $export = require('./$.export')
  3. , expm1 = require('./$.math-expm1')
  4. , exp = Math.exp;
  5. $export($export.S, 'Math', {
  6. tanh: function tanh(x){
  7. var a = expm1(x = +x)
  8. , b = expm1(-x);
  9. return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
  10. }
  11. });