Skip to content

Commit

Permalink
Simplify logic for Math.tanh
Browse files Browse the repository at this point in the history
  • Loading branch information
benjoffe committed Mar 1, 2016
1 parent 6bca7e1 commit 072c2e4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1960,11 +1960,8 @@
// can exit early at +-20 as JS loses precision for true value at this integer
if (x >= 20) { return 1; }
if (x <= -20) { return -1; }
var a = Math.expm1(x);
var b = Math.expm1(-x);
if (a === Infinity) { return 1; }
if (b === Infinity) { return -1; }
return (a - b) / (Math.exp(x) + Math.exp(-x));

return (Math.expm1(x) - Math.expm1(-x)) / (Math.exp(x) + Math.exp(-x));
},

trunc: function trunc(value) {
Expand Down

0 comments on commit 072c2e4

Please sign in to comment.